mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 08:10:17 +01:00
core: don't auto-launch logind (bgo #741572)
logind might need the network for login information, and apparently
it fails hard if the network isn't up, and apparently it doesn't
recover when the network does come up. Since NM doesn't actually
care about suspend/resume until logind is running anyway, don't
auto-launch it. Just wait until it shows up.
While we're at it, make proxy creation async.
https://bugzilla.gnome.org/show_bug.cgi?id=741572
(cherry picked from commit 5a051ad716)
This commit is contained in:
parent
ff362700f1
commit
c140f64b39
1 changed files with 44 additions and 9 deletions
|
|
@ -148,24 +148,59 @@ signal_cb (GDBusProxy *proxy,
|
|||
}
|
||||
|
||||
static void
|
||||
sleep_setup (NMSleepMonitor *self)
|
||||
name_owner_cb (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
GDBusProxy *proxy = G_DBUS_PROXY (object);
|
||||
NMSleepMonitor *self = NM_SLEEP_MONITOR (user_data);
|
||||
char *owner;
|
||||
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
|
||||
self->sd_proxy = g_dbus_proxy_new_sync (bus, 0, NULL,
|
||||
SD_NAME, SD_PATH, SD_INTERFACE,
|
||||
NULL, NULL);
|
||||
g_object_unref (bus);
|
||||
g_assert (proxy == self->sd_proxy);
|
||||
|
||||
owner = g_dbus_proxy_get_name_owner (proxy);
|
||||
if (owner)
|
||||
take_inhibitor (self);
|
||||
else
|
||||
drop_inhibitor (self);
|
||||
g_free (owner);
|
||||
}
|
||||
|
||||
static void
|
||||
on_proxy_acquired (GObject *object,
|
||||
GAsyncResult *res,
|
||||
NMSleepMonitor *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *owner;
|
||||
|
||||
self->sd_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
if (!self->sd_proxy) {
|
||||
nm_log_warn (LOGD_SUSPEND, "Failed to acquire logind proxy: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_signal_connect (self->sd_proxy, "notify::g-name-owner", G_CALLBACK (name_owner_cb), self);
|
||||
g_signal_connect (self->sd_proxy, "g-signal", G_CALLBACK (signal_cb), self);
|
||||
|
||||
owner = g_dbus_proxy_get_name_owner (self->sd_proxy);
|
||||
if (owner)
|
||||
take_inhibitor (self);
|
||||
g_free (owner);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_sleep_monitor_init (NMSleepMonitor *self)
|
||||
{
|
||||
self->inhibit_fd = -1;
|
||||
sleep_setup (self);
|
||||
take_inhibitor (self);
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
|
||||
NULL,
|
||||
SD_NAME, SD_PATH, SD_INTERFACE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) on_proxy_acquired, self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue