Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Unified Diff: src/service_manager.h

Issue 5333003: cashew: do not delete DBus::ObjectProxy objects from D-Bus callbacks (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/service_manager.h
diff --git a/src/service_manager.h b/src/service_manager.h
index e12fd91503cfb92119166f6cad63103a599b79f4..f4175b343bac1dc0ebbe266d6b91e47b2e9f2505 100644
--- a/src/service_manager.h
+++ b/src/service_manager.h
@@ -5,6 +5,8 @@
#ifndef SRC_SERVICE_MANAGER_H_
#define SRC_SERVICE_MANAGER_H_
+#include <glib.h>
+
#include <map>
#include <string>
#include <vector>
@@ -22,6 +24,9 @@ class CashewServer;
// map of service path names to Service objects
typedef std::map<std::string, Service*> ServiceMap;
+// vector of Service objects
+typedef std::vector<Service*> ServiceList;
+
// vector of DBus::Path objects (strings) representing service path names
typedef std::vector<DBus::Path> ServicePathList;
@@ -30,7 +35,8 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy {
public:
- explicit ServiceManager(DBus::Connection& connection); // NOLINT
+ explicit ServiceManager(DBus::Connection& connection, // NOLINT
+ GMainLoop * const main_loop);
virtual ~ServiceManager();
// look up a service by its path name
@@ -92,11 +98,20 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// set the retrying flag
virtual void OnRetryingGetProperties(bool retrying);
+ // get deferred service deletion source id
+ virtual guint GetDeferredServiceDeletionSourceId() const;
+
+ // set deferred service deletion source id
+ virtual void SetDeferredServiceDeletionSourceId(guint source_id);
+
private:
// D-Bus connection owned by our creator
// shared with Service objs that we create
DBus::Connection& connection_;
+ // glib main loop
+ GMainLoop * const main_loop_;
+
// collection of Service objs representing cellular services
ServiceMap services_;
@@ -123,8 +138,30 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// and our subsequent timer calls
bool retrying_get_properties_;
- // delete a collection of services
- void DeleteServices(ServiceMap *service_map);
+ // Service objects pending deletion from the main loop
+ // we need to do this to work around a dbus-c++ deadlock issue that arises
+ // when we send a D-Bus message from a D-Bus callback
+ ServiceList services_pending_deletion_;
+
+ // glib source id for deferred service deletion
+ guint deferred_service_deletion_source_id_;
+
+ // delete a collection of services as soon as possible
+ // calls DeleteServiceOrScheduleForLaterDeletion (below) for each service
+ void DeleteServicesWhenPossible(ServiceMap *service_map);
+
+ // deletes members of |services_pending_deletion_| immediately
+ void DeletePendingServices();
+
+ // delete a service as soon as possible
+ // the service is deleted immediately if the main loop is not running
+ // otherwise, it is scheduled for deletion from the main loop
+ void DeleteServiceOrScheduleForLaterDeletion(Service *service);
+
+ // glib integration: static wrapper for DeletePendingServices
+ // takes object ptr as data and invokes object->DeletePendingServices()
+ // does not reschedule itself to run again
+ static gboolean StaticDeletePendingServicesCallback(gpointer data);
// glib integration: static wrapper for GetFlimflamProperties
// takes object ptr as data and invokes object->GetFlimflamProperties()

Powered by Google App Engine
This is Rietveld 408576698