X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-dbus.c;h=800e2a51b63185cfa6a0b7bb18ffd10a33fb5a45;hp=b0c15e25332bc5065cf8c5fefc8c31fd1b98ec67;hb=d76bb3c179b7a32b109e39aa87ff09c8f5a8c178;hpb=5b3e932f4e40d2c5523757242e00e4f4e6ae89cd diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index b0c15e253..800e2a51b 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -28,7 +28,7 @@ #include "strv.h" #include "mkdir.h" #include "path-util.h" -#include "special.h" +// #include "special.h" #include "sleep-config.h" #include "fileio-label.h" #include "unit-name.h" @@ -860,6 +860,8 @@ static int method_release_session(sd_bus_message *message, void *userdata, sd_bu if (r < 0) return r; + session_add_to_gc_queue(session); + return sd_bus_reply_method_return(message, NULL); } @@ -1434,6 +1436,28 @@ int manager_set_lid_switch_ignore(Manager *m, usec_t until) { return r; } +static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) { + + static const char * const signal_name[_INHIBIT_WHAT_MAX] = { + [INHIBIT_SHUTDOWN] = "PrepareForShutdown", + [INHIBIT_SLEEP] = "PrepareForSleep" + }; + + int active = _active; + + assert(m); + assert(w >= 0); + assert(w < _INHIBIT_WHAT_MAX); + assert(signal_name[w]); + + return sd_bus_emit_signal(m->bus, + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + signal_name[w], + "b", + active); +} + static int execute_shutdown_or_sleep( Manager *m, InhibitWhat w, @@ -1487,6 +1511,12 @@ static int execute_shutdown_or_sleep( m->action_what = w; #endif // 0 + if (w == INHIBIT_SLEEP) + /* And we're back. */ + send_prepare_for(m, w, false); + + m->action_what = 0; + /* Make sure the lid switch is ignored for a while */ manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec); @@ -1567,28 +1597,6 @@ static int delay_shutdown_or_sleep( return 0; } -static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) { - - static const char * const signal_name[_INHIBIT_WHAT_MAX] = { - [INHIBIT_SHUTDOWN] = "PrepareForShutdown", - [INHIBIT_SLEEP] = "PrepareForSleep" - }; - - int active = _active; - - assert(m); - assert(w >= 0); - assert(w < _INHIBIT_WHAT_MAX); - assert(signal_name[w]); - - return sd_bus_emit_signal(m->bus, - "/org/freedesktop/login1", - "org.freedesktop.login1.Manager", - signal_name[w], - "b", - active); -} - int bus_manager_shutdown_or_sleep_now_or_later( Manager *m, HandleAction action, @@ -1990,8 +1998,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd m->scheduled_shutdown_timeout_source = sd_event_source_unref(m->scheduled_shutdown_timeout_source); m->wall_message_timeout_source = sd_event_source_unref(m->wall_message_timeout_source); m->nologin_timeout_source = sd_event_source_unref(m->nologin_timeout_source); - free(m->scheduled_shutdown_type); - m->scheduled_shutdown_type = NULL; + m->scheduled_shutdown_type = mfree(m->scheduled_shutdown_type); m->scheduled_shutdown_timeout = 0; if (cancelled) { @@ -2613,7 +2620,6 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err return 0; } -#endif // 0 int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *path, *unit; @@ -2702,6 +2708,7 @@ int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error return 0; } +#endif // 0 int manager_send_changed(Manager *manager, const char *property, ...) { char **l;