mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-14 04:00:33 +01:00
libnm/client: don't consider client running if we got no NMManager
We silently tolerate NetworkManager not responding at all (easily
reproduced with e.g. pkill -STOP NetworkManager):
$ LIBNM_CLIENT_DEBUG=trace nmcli c show dummy666
libnm-dbus[23540]: <debug> [3316.81989] nmclient[ddafb84b8deebe4a]: new NMClient instance
libnm-dbus[23540]: <debug> [3316.81998] nmclient[ddafb84b8deebe4a]: starting async initialization...
libnm-dbus[23540]: <debug> [3316.82461] nmclient[ddafb84b8deebe4a]: name owner changed: (null) -> ":1.2"
libnm-dbus[23540]: <debug> [3316.82464] nmclient[ddafb84b8deebe4a]: fetch all
libnm-dbus[23540]: <debug> [3341.85715] nmclient[ddafb84b8deebe4a]: GetManagedObjects() call failed: Timeout was reached
libnm-dbus[23540]: <debug> [3341.85740] nmclient[ddafb84b8deebe4a]: async init complete with success
Error: dummy666 - no such connection profile.
libnm-dbus[23540]: <debug> [3341.86723] nmclient[ddafb84b8deebe4a]: release all
libnm-dbus[23540]: <debug> [3341.86798] nmclient[ddafb84b8deebe4a]: disposed
$
As a comment in _dbus_get_managed_objects_cb() explains, this is sort of
intentional. NetworkManager might just be shutting down and the libnm
users will eventually see the objects once a new daemon starts up.
This may make some sense for long-running clients ("nmcli monitor",
various desktop environments), but not for one-shot invocations that
require the daemon running, such as those of "nmcli c ...".
Let's not consider the client running unless we actually got the manager
object. That way the error message will make more sense:
$ LIBNM_CLIENT_DEBUG=trace nmcli c show dummy666
libnm-dbus[24730]: <debug> [5360.95480] nmclient[8cb898d3c891e210]: new NMClient instance
libnm-dbus[24730]: <debug> [5360.95487] nmclient[8cb898d3c891e210]: starting async initialization...
libnm-dbus[24730]: <debug> [5360.95901] nmclient[8cb898d3c891e210]: name owner changed: (null) -> ":1.2"
libnm-dbus[24730]: <debug> [5360.95904] nmclient[8cb898d3c891e210]: fetch all
libnm-dbus[24730]: <debug> [5385.98487] nmclient[8cb898d3c891e210]: GetManagedObjects() call failed: Timeout was reached
libnm-dbus[24730]: <debug> [5385.98497] nmclient[8cb898d3c891e210]: async init complete with success
Error: NetworkManager is not running.
libnm-dbus[24730]: <debug> [5385.98571] nmclient[8cb898d3c891e210]: release all
libnm-dbus[24730]: <debug> [5385.98698] nmclient[8cb898d3c891e210]: disposed
$
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1502
This commit is contained in:
parent
fd7175969c
commit
5e234fa0c9
1 changed files with 11 additions and 6 deletions
|
|
@ -378,7 +378,7 @@ static void name_owner_changed_cb(GDBusConnection *connection,
|
|||
|
||||
static void name_owner_get_call(NMClient *self);
|
||||
|
||||
static void _set_nm_running(NMClient *self);
|
||||
static void _set_nm_running(NMClient *self, gboolean queue_notify);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -2724,6 +2724,7 @@ _obj_handle_dbus_changes(NMClient *self, NMLDBusObject *dbobj)
|
|||
if (dbobj->dbus_path == _dbus_path_nm) {
|
||||
nm_assert(!priv->dbobj_nm);
|
||||
priv->dbobj_nm = dbobj;
|
||||
_set_nm_running(self, TRUE);
|
||||
} else if (dbobj->dbus_path == _dbus_path_settings) {
|
||||
nm_assert(!priv->dbobj_settings);
|
||||
priv->dbobj_settings = dbobj;
|
||||
|
|
@ -2783,6 +2784,7 @@ _obj_handle_dbus_changes(NMClient *self, NMLDBusObject *dbobj)
|
|||
if (dbobj->dbus_path == _dbus_path_nm) {
|
||||
nm_assert(priv->dbobj_nm == dbobj);
|
||||
priv->dbobj_nm = NULL;
|
||||
_set_nm_running(self, TRUE);
|
||||
nml_dbus_property_o_clear_many(priv->nm.property_o,
|
||||
G_N_ELEMENTS(priv->nm.property_o),
|
||||
self);
|
||||
|
|
@ -2936,7 +2938,7 @@ _dbus_handle_changes_commit(NMClient *self, gboolean allow_init_start_check_comp
|
|||
|
||||
_nm_client_notify_event_emit(self);
|
||||
|
||||
_set_nm_running(self);
|
||||
_set_nm_running(self, FALSE);
|
||||
|
||||
if (allow_init_start_check_complete)
|
||||
_init_start_check_complete(self);
|
||||
|
|
@ -4083,15 +4085,18 @@ nm_client_get_startup(NMClient *client)
|
|||
}
|
||||
|
||||
static void
|
||||
_set_nm_running(NMClient *self)
|
||||
_set_nm_running(NMClient *self, gboolean queue_notify)
|
||||
{
|
||||
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE(self);
|
||||
gboolean nm_running;
|
||||
|
||||
nm_running = priv->name_owner && !priv->get_managed_objects_cancellable;
|
||||
nm_running = priv->dbobj_nm && priv->name_owner && !priv->get_managed_objects_cancellable;
|
||||
if (priv->nm_running != nm_running) {
|
||||
priv->nm_running = nm_running;
|
||||
_notify(self, PROP_NM_RUNNING);
|
||||
if (queue_notify) {
|
||||
_nm_client_queue_notify_object(self, self, obj_properties[PROP_NM_RUNNING]);
|
||||
} else
|
||||
_notify(self, PROP_NM_RUNNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7171,7 +7176,7 @@ name_owner_changed(NMClient *self, const char *name_owner)
|
|||
if (changed && priv->name_owner)
|
||||
_init_fetch_all(self);
|
||||
|
||||
_set_nm_running(self);
|
||||
_set_nm_running(self, FALSE);
|
||||
|
||||
if (priv->init_data) {
|
||||
nm_auto_pop_gmaincontext GMainContext *main_context = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue