[gupnp] Work-around a deadlock when quickly creating/releasing GDBusConnections



commit a378c4c9094372652ddb55286f998688571f61fc
Author: Jens Georg <mail jensge org>
Date:   Fri Apr 20 16:55:55 2012 +0200

    Work-around a deadlock when quickly creating/releasing GDBusConnections
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667494

 libgupnp/gupnp-connman-manager.c |    7 +++++++
 libgupnp/gupnp-context-manager.c |    7 +++++++
 libgupnp/gupnp-network-manager.c |    5 +++++
 3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/libgupnp/gupnp-connman-manager.c b/libgupnp/gupnp-connman-manager.c
index 8b9952f..076b831 100644
--- a/libgupnp/gupnp-connman-manager.c
+++ b/libgupnp/gupnp-connman-manager.c
@@ -57,6 +57,7 @@ struct _GUPnPConnmanManagerPrivate {
         GSource    *idle_context_creation_src;
         GHashTable *cm_services;
         guint      sig_change_id;
+        GDBusConnection *system_bus;
 };
 
 #define CM_DBUS_CONNMAN_NAME      "net.connman"
@@ -668,6 +669,8 @@ gupnp_connman_manager_dispose (GObject *object)
                 priv->cm_services = NULL;
         }
 
+        g_clear_object (&(priv->system_bus));
+
         /* Call super */
         object_class = G_OBJECT_CLASS (gupnp_connman_manager_parent_class);
         object_class->dispose (object);
@@ -681,6 +684,10 @@ gupnp_connman_manager_constructed (GObject *object)
 
         manager = GUPNP_CONNMAN_MANAGER (object);
 
+        manager->priv->system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
+                                                    NULL,
+                                                    NULL);
+
         init_connman_manager (manager);
 
         schedule_loopback_context_creation (manager);
diff --git a/libgupnp/gupnp-context-manager.c b/libgupnp/gupnp-context-manager.c
index ff454c9..4b4b9bb 100644
--- a/libgupnp/gupnp-context-manager.c
+++ b/libgupnp/gupnp-context-manager.c
@@ -327,11 +327,15 @@ gupnp_context_manager_new (GMainContext *main_context,
 GUPnPContextManager *
 gupnp_context_manager_create (guint port)
 {
+#if defined(USE_NETWORK_MANAGER) || defined (USE_CONNMAN)
+        GDBusConnection *system_bus;
+#endif
         GUPnPContextManager *impl;
         GType impl_type = G_TYPE_INVALID;
 
 #ifdef USE_NETWORK_MANAGER
 #include "gupnp-network-manager.h"
+        system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
 
         if (gupnp_network_manager_is_available ())
                 impl_type = GUPNP_TYPE_NETWORK_MANAGER;
@@ -353,6 +357,9 @@ gupnp_context_manager_create (guint port)
                              "port", port,
                              NULL);
 
+#if defined(USE_NETWORK_MANAGER) || defined(USE_CONNMAN)
+        g_object_unref (system_bus);
+#endif
         return impl;
 }
 
diff --git a/libgupnp/gupnp-network-manager.c b/libgupnp/gupnp-network-manager.c
index 312720b..b8a537b 100644
--- a/libgupnp/gupnp-network-manager.c
+++ b/libgupnp/gupnp-network-manager.c
@@ -114,6 +114,8 @@ struct _GUPnPNetworkManagerPrivate {
         GList *nm_devices;
 
         GCancellable *cancellable;
+
+        GDBusConnection *system_bus;
 };
 
 static NMDevice *
@@ -649,6 +651,7 @@ gupnp_network_manager_constructed (GObject *object)
 
         priv->cancellable = g_cancellable_new ();
         priv->nm_devices = NULL;
+        priv->system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
 
         init_network_manager (manager);
 
@@ -692,6 +695,8 @@ gupnp_network_manager_dispose (GObject *object)
                 priv->cancellable = NULL;
         }
 
+        g_clear_object (&(priv->system_bus));
+
         /* Call super */
         object_class = G_OBJECT_CLASS (gupnp_network_manager_parent_class);
         object_class->dispose (object);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]