mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-23 08:30:38 +01:00
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.
This commit is contained in:
parent
098d655ef1
commit
648270d469
6 changed files with 33 additions and 7 deletions
|
|
@ -68,6 +68,12 @@
|
|||
#include "nm-version.h"
|
||||
#include "nm-vpn-dbus-interface.h"
|
||||
|
||||
#define NM_UTILS_CLEAR_CANCELLABLE(c) \
|
||||
if (c) { \
|
||||
g_cancellable_cancel (c); \
|
||||
g_clear_object (&c); \
|
||||
}
|
||||
|
||||
const char *_nm_setting_ip4_config_get_address_label (NMSettingIP4Config *setting,
|
||||
guint32 i);
|
||||
gboolean _nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *setting,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,7 +1208,8 @@ 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);
|
||||
}
|
||||
|
||||
|
|
@ -1223,6 +1225,8 @@ nm_running_changed_cb (GObject *object,
|
|||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
|
||||
if (!nm_manager_get_nm_running (manager)) {
|
||||
NM_UTILS_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 +1250,11 @@ 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);
|
||||
|
||||
NM_UTILS_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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,7 +605,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -623,6 +625,8 @@ nm_running_changed (GObject *object,
|
|||
GPtrArray *connections;
|
||||
int i;
|
||||
|
||||
NM_UTILS_CLEAR_CANCELLABLE (priv->props_cancellable);
|
||||
|
||||
/* Clear connections */
|
||||
connections = priv->all_connections;
|
||||
priv->all_connections = g_ptr_array_new ();
|
||||
|
|
@ -645,7 +649,10 @@ 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);
|
||||
|
||||
NM_UTILS_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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue