summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-10-21 19:43:34 -0500
committerDan Williams <dcbw@redhat.com>2014-11-04 12:38:32 -0600
commitca0a4f4068e1d3bf9e99d00be273003db0862e6a (patch)
treed4fa55ddfa5b042a3b19d1d41b2dc57992ee493e
parent1b40c95c846cbb85547c826d329415b4ece0bce1 (diff)
downloadNetworkManager-ca0a4f4068e1d3bf9e99d00be273003db0862e6a.tar.gz
libnm: cancel NMRemoteSettings/NMManager property reload when NM quits
If the operation isn't canceled it returns an error, printing this: /libnm/client-nm-running: (/home/dcbw/Development/fdo/NetworkManager/libnm/tests/.libs/lt-test-nm-client:17983): libnm-WARNING **: updated_properties: error reading NMRemoteSettings properties: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message did not receive a reply (timeout by message bus) /bin/sh: line 5: 17983 Trace/breakpoint trap ./libnm-test-launch.sh ${dir}$tst FAIL: test-nm-client which screws up testcases because they don't expect this message. And in this case, since libnm knows that NM is exiting and will just clear out the properties anyway, it's useless to print the message.
-rw-r--r--libnm/nm-device.c1
-rw-r--r--libnm/nm-manager.c16
-rw-r--r--libnm/nm-object-private.h1
-rw-r--r--libnm/nm-object.c9
-rw-r--r--libnm/nm-remote-settings.c15
5 files changed, 35 insertions, 7 deletions
diff --git a/libnm/nm-device.c b/libnm/nm-device.c
index 5999ed23d2..5a1caf6d9f 100644
--- a/libnm/nm-device.c
+++ b/libnm/nm-device.c
@@ -275,6 +275,7 @@ device_state_changed (NMDBusDevice *proxy,
data->new_state = new_state;
data->reason = reason;
_nm_object_reload_properties_async (NM_OBJECT (user_data),
+ NULL,
device_state_change_reloaded,
data);
}
diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c
index 3f6ef585c0..afd84bbc67 100644
--- a/libnm/nm-manager.c
+++ b/libnm/nm-manager.c
@@ -53,6 +53,7 @@ G_DEFINE_TYPE_WITH_CODE (NMManager, nm_manager, NM_TYPE_OBJECT,
typedef struct {
NMDBusManager *manager_proxy;
+ GCancellable *props_cancellable;
char *version;
NMState state;
gboolean startup;
@@ -1207,13 +1208,18 @@ updated_properties (GObject *object, GAsyncResult *result, gpointer user_data)
GError *error = NULL;
if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) {
- g_warning ("%s: error reading NMManager properties: %s", __func__, error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("%s: error reading NMManager properties: %s", __func__, error->message);
g_error_free (error);
}
_nm_object_queue_notify (NM_OBJECT (manager), NM_MANAGER_NM_RUNNING);
}
+#define CLEAR_CANCELLABLE(c) \
+ if (c) g_cancellable_cancel (c); \
+ g_clear_object (&c);
+
static void
nm_running_changed_cb (GObject *object,
GParamSpec *pspec,
@@ -1223,6 +1229,8 @@ nm_running_changed_cb (GObject *object,
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
if (!nm_manager_get_nm_running (manager)) {
+ CLEAR_CANCELLABLE (priv->props_cancellable);
+
priv->state = NM_STATE_UNKNOWN;
priv->startup = FALSE;
_nm_object_queue_notify (NM_OBJECT (manager), NM_MANAGER_NM_RUNNING);
@@ -1246,7 +1254,9 @@ nm_running_changed_cb (GObject *object,
_nm_object_cache_clear ();
} else {
_nm_object_suppress_property_updates (NM_OBJECT (manager), FALSE);
- _nm_object_reload_properties_async (NM_OBJECT (manager), updated_properties, manager);
+ CLEAR_CANCELLABLE (priv->props_cancellable);
+ priv->props_cancellable = g_cancellable_new ();
+ _nm_object_reload_properties_async (NM_OBJECT (manager), priv->props_cancellable, updated_properties, manager);
manager_recheck_permissions (priv->manager_proxy, manager);
}
}
@@ -1398,6 +1408,8 @@ dispose (GObject *object)
g_hash_table_destroy (priv->permissions);
priv->permissions = NULL;
+ g_clear_object (&priv->props_cancellable);
+
G_OBJECT_CLASS (nm_manager_parent_class)->dispose (object);
}
diff --git a/libnm/nm-object-private.h b/libnm/nm-object-private.h
index 82e38f4d21..fa8b21d6c1 100644
--- a/libnm/nm-object-private.h
+++ b/libnm/nm-object-private.h
@@ -43,6 +43,7 @@ void _nm_object_register_properties (NMObject *object,
gboolean _nm_object_reload_properties (NMObject *object, GError **error);
void _nm_object_reload_properties_async (NMObject *object,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _nm_object_reload_properties_finish (NMObject *object,
diff --git a/libnm/nm-object.c b/libnm/nm-object.c
index f4162f8bbc..cda7729fe4 100644
--- a/libnm/nm-object.c
+++ b/libnm/nm-object.c
@@ -246,7 +246,7 @@ init_async_got_proxy (GObject *object, GAsyncResult *result, gpointer user_data)
NM_OBJECT_GET_CLASS (self)->init_dbus (self);
- _nm_object_reload_properties_async (init_data->object, init_async_got_properties, init_data);
+ _nm_object_reload_properties_async (init_data->object, init_data->cancellable, init_async_got_properties, init_data);
}
static void
@@ -1550,7 +1550,10 @@ reload_got_properties (GObject *proxy,
}
void
-_nm_object_reload_properties_async (NMObject *object, GAsyncReadyCallback callback, gpointer user_data)
+_nm_object_reload_properties_async (NMObject *object,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
GSimpleAsyncResult *simple;
@@ -1583,7 +1586,7 @@ _nm_object_reload_properties_async (NMObject *object, GAsyncReadyCallback callba
"GetAll",
g_variant_new ("(s)", interface),
G_DBUS_CALL_FLAGS_NONE, -1,
- NULL,
+ cancellable,
reload_got_properties, object);
}
}
diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c
index a37cbe9f8b..83446cd526 100644
--- a/libnm/nm-remote-settings.c
+++ b/libnm/nm-remote-settings.c
@@ -44,6 +44,7 @@ typedef struct {
NMDBusSettings *proxy;
GPtrArray *all_connections;
GPtrArray *visible_connections;
+ GCancellable *props_cancellable;
/* AddConnectionInfo objects that are waiting for the connection to become initialized */
GSList *add_list;
@@ -604,11 +605,16 @@ updated_properties (GObject *object, GAsyncResult *result, gpointer user_data)
GError *error = NULL;
if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) {
- g_warning ("%s: error reading NMRemoteSettings properties: %s", __func__, error->message);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("%s: error reading NMRemoteSettings properties: %s", __func__, error->message);
g_error_free (error);
}
}
+#define CLEAR_CANCELLABLE(c) \
+ if (c) g_cancellable_cancel (c); \
+ g_clear_object (&c);
+
static void
nm_running_changed (GObject *object,
GParamSpec *pspec,
@@ -623,6 +629,8 @@ nm_running_changed (GObject *object,
GPtrArray *connections;
int i;
+ CLEAR_CANCELLABLE (priv->props_cancellable);
+
/* Clear connections */
connections = priv->all_connections;
priv->all_connections = g_ptr_array_new ();
@@ -645,7 +653,9 @@ nm_running_changed (GObject *object,
_nm_object_suppress_property_updates (NM_OBJECT (self), TRUE);
} else {
_nm_object_suppress_property_updates (NM_OBJECT (self), FALSE);
- _nm_object_reload_properties_async (NM_OBJECT (self), updated_properties, self);
+ CLEAR_CANCELLABLE (priv->props_cancellable);
+ priv->props_cancellable = g_cancellable_new ();
+ _nm_object_reload_properties_async (NM_OBJECT (self), priv->props_cancellable, updated_properties, self);
}
g_object_thaw_notify (object);
@@ -731,6 +741,7 @@ dispose (GObject *object)
g_clear_pointer (&priv->visible_connections, g_ptr_array_unref);
g_clear_pointer (&priv->hostname, g_free);
+ g_clear_object (&priv->props_cancellable);
G_OBJECT_CLASS (nm_remote_settings_parent_class)->dispose (object);
}