From 7e46f3ff9238635d6d7c9773c9cbaf6cb4035af9 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Wed, 13 Jun 2018 17:37:19 +0200 Subject: [PATCH] Move bus_manager_shutdown_or_sleep_now_or_later() back to logind-dbus.c --- src/login/elogind-dbus.c | 36 ------------------------------------ src/login/logind-dbus.c | 15 +++++++++++---- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/login/elogind-dbus.c b/src/login/elogind-dbus.c index 646a4831c..28a9cd489 100644 --- a/src/login/elogind-dbus.c +++ b/src/login/elogind-dbus.c @@ -186,42 +186,6 @@ int execute_shutdown_or_sleep( return 0; } -int bus_manager_shutdown_or_sleep_now_or_later( - Manager *m, - HandleAction action, - InhibitWhat w, - sd_bus_error *error) { - - bool delayed; - int r; - - assert(m); - assert(w >= 0); - assert(w <= _INHIBIT_WHAT_MAX); - - /* Tell everybody to prepare for shutdown/sleep */ - (void) send_prepare_for(m, w, true); - - delayed = - m->inhibit_delay_max > 0 && - manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0, NULL); - - log_debug_elogind("%s called for %s (%sdelayed)", __FUNCTION__, - handle_action_to_string(action), - delayed ? "" : "NOT "); - - if (delayed) - /* Shutdown is delayed, keep in mind what we - * want to do, and start a timeout */ - r = delay_shutdown_or_sleep(m, w, action); - else - /* Shutdown is not delayed, execute it - * immediately */ - r = execute_shutdown_or_sleep(m, w, action, error); - - return r; -} - static int method_do_shutdown_or_sleep( Manager *m, sd_bus_message *message, diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 46d7a4f25..e2ffc6579 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1758,21 +1758,28 @@ int delay_shutdown_or_sleep( return 0; } -#if 0 /// elogind has its own variant in elogind-dbus.c int bus_manager_shutdown_or_sleep_now_or_later( Manager *m, +#if 0 /// elogind has HandleAction instead of const char* unit_name const char *unit_name, +#else + HandleAction unit_name, +#endif // 0 InhibitWhat w, sd_bus_error *error) { - bool delayed; int r; assert(m); +#if 0 /// for elogind only w has to be checked. assert(unit_name); assert(w > 0); assert(w <= _INHIBIT_WHAT_MAX); assert(!m->action_job); +#else + assert(w > 0); + assert(w <= _INHIBIT_WHAT_MAX); +#endif // 0 /* Tell everybody to prepare for shutdown/sleep */ (void) send_prepare_for(m, w, true); @@ -1782,8 +1789,9 @@ int bus_manager_shutdown_or_sleep_now_or_later( manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0, NULL); log_debug_elogind("%s called for %s (%sdelayed)", __FUNCTION__, - handle_action_to_string(action), + handle_action_to_string(unit_name), delayed ? "" : "NOT "); + if (delayed) /* Shutdown is delayed, keep in mind what we * want to do, and start a timeout */ @@ -1795,7 +1803,6 @@ int bus_manager_shutdown_or_sleep_now_or_later( return r; } -#endif // 0 #if 0 /// elogind-dbus.c needs to access this static int verify_shutdown_creds( -- 2.30.2