chiark / gitweb /
Move bus_manager_shutdown_or_sleep_now_or_later() back to logind-dbus.c
authorSven Eden <yamakuzure@gmx.net>
Wed, 13 Jun 2018 15:37:19 +0000 (17:37 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 29 Jun 2018 05:12:51 +0000 (07:12 +0200)
src/login/elogind-dbus.c
src/login/logind-dbus.c

index 646a4831ccb8a1d7e10c1c263f9175233d384f50..28a9cd4894c8115ac5fbe5e0cb86bfd2471854a2 100644 (file)
@@ -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,
index 46d7a4f25ad391d8c43d7f1ee81dfa8fc731e534..e2ffc65791349af98c9c1753b9e39283fd4ed7b3 100644 (file)
@@ -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(