summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-10-12 14:17:16 +0200
committerThomas Haller <thaller@redhat.com>2019-10-18 22:09:18 +0200
commitfe24797241f359979ffb6245c035265453a1eb1c (patch)
treed531ed3c494dbd58e998f81631ccd03ce3d60510
parentec6391981862fcc32f8a5522fdcff1bfd2b6d4ff (diff)
downloadNetworkManager-fe24797241f359979ffb6245c035265453a1eb1c.tar.gz
libnm: remember the caller's GMainContext when creating NMClient
We will require this later. The NMClient shall be tied to the GMainContext at the moment when the instance gets created. This allows the user to have multiple, indendent NMClient instances (on different threads and GMainContext). Currently this is still unused, it will be later.
-rw-r--r--libnm/nm-client.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c
index d4596358e8..3774daca19 100644
--- a/libnm/nm-client.c
+++ b/libnm/nm-client.c
@@ -135,6 +135,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
+ GMainContext *main_context;
NMManager *manager;
NMRemoteSettings *settings;
NMDnsManager *dns_manager;
@@ -3660,7 +3661,7 @@ init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
/*****************************************************************************/
static void
-nm_client_init (NMClient *client)
+nm_client_init (NMClient *self)
{
}
@@ -3751,6 +3752,17 @@ nm_client_new_finish (GAsyncResult *result, GError **error)
}
static void
+constructed (GObject *object)
+{
+ NMClient *self = NM_CLIENT (object);
+ NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
+
+ priv->main_context = g_main_context_ref_thread_default ();
+
+ G_OBJECT_CLASS (nm_client_parent_class)->constructed (object);
+}
+
+static void
dispose (GObject *object)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
@@ -3787,10 +3799,9 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_client_parent_class)->dispose (object);
- if (priv->udev) {
- udev_unref (priv->udev);
- priv->udev = NULL;
- }
+ nm_clear_pointer (&priv->udev, udev_unref);
+
+ nm_clear_pointer (&priv->main_context, g_main_context_unref);
nm_clear_g_free (&priv->name_owner_cached);
}
@@ -3804,6 +3815,7 @@ nm_client_class_init (NMClientClass *client_class)
object_class->get_property = get_property;
object_class->set_property = set_property;
+ object_class->constructed = constructed;
object_class->dispose = dispose;
/**