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

index 818c3676e748afaf69bea4553b11f5114934e8e5..646a4831ccb8a1d7e10c1c263f9175233d384f50 100644 (file)
@@ -186,41 +186,6 @@ int execute_shutdown_or_sleep(
         return 0;
 }
 
-static int delay_shutdown_or_sleep(
-                Manager *m,
-                InhibitWhat w,
-                HandleAction action) {
-
-        int r;
-        usec_t timeout_val;
-
-        assert(m);
-        assert(w >= 0);
-        assert(w < _INHIBIT_WHAT_MAX);
-
-        timeout_val = now(CLOCK_MONOTONIC) + m->inhibit_delay_max;
-
-        if (m->inhibit_timeout_source) {
-                r = sd_event_source_set_time(m->inhibit_timeout_source, timeout_val);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_source_set_time() failed: %m");
-
-                r = sd_event_source_set_enabled(m->inhibit_timeout_source, SD_EVENT_ONESHOT);
-                if (r < 0)
-                        return log_error_errno(r, "sd_event_source_set_enabled() failed: %m");
-        } else {
-                r = sd_event_add_time(m->event, &m->inhibit_timeout_source, CLOCK_MONOTONIC,
-                                      timeout_val, 0, manager_inhibit_timeout_handler, m);
-                if (r < 0)
-                        return r;
-        }
-
-        m->pending_action = action;
-        m->action_what = w;
-
-        return 0;
-}
-
 int bus_manager_shutdown_or_sleep_now_or_later(
                 Manager *m,
                 HandleAction action,
index deac06f7350d26924d164ed117e57c6fe1e17da1..182426a0e97e27693d4c22e58f48a9f7f6705f27 100644 (file)
@@ -36,6 +36,7 @@ int method_suspend     (sd_bus_message *message, void *userdata, sd_bus_error *e
 
 
 /* prototypes for former static functions in logind-dbus.c */
+int delay_shutdown_or_sleep(Manager *m, InhibitWhat w, HandleAction action);
 int  manager_inhibit_timeout_handler(sd_event_source *s, uint64_t usec, void *userdata);
 void reset_scheduled_shutdown(Manager *m);
 int  send_prepare_for(Manager *m, InhibitWhat w, bool _active);
index 3ac67a4441a7d46a21bcb6a9b0467236bfb98613..46d7a4f25ad391d8c43d7f1ee81dfa8fc731e534 100644 (file)
@@ -1710,19 +1710,26 @@ int manager_inhibit_timeout_handler(
         return (r < 0) ? r : 0;
 }
 
-#if 0 /// elogind has its own variant in elogind-dbus.c
+#if 0 /// elogind does not have unit_name but action
 static int delay_shutdown_or_sleep(
                 Manager *m,
                 InhibitWhat w,
                 const char *unit_name) {
-
+#else
+int delay_shutdown_or_sleep(
+                Manager *m,
+                InhibitWhat w,
+                HandleAction action) {
+#endif // 0
         int r;
         usec_t timeout_val;
 
         assert(m);
         assert(w >= 0);
         assert(w < _INHIBIT_WHAT_MAX);
+#if 0 /// UNNEEDED by elogind
         assert(unit_name);
+#endif // 0
 
         timeout_val = now(CLOCK_MONOTONIC) + m->inhibit_delay_max;
 
@@ -1741,12 +1748,15 @@ static int delay_shutdown_or_sleep(
                         return r;
         }
 
+#if 0 /// elogind does not have unit_name but pendig_action
         m->action_unit = unit_name;
+#else
+        m->pending_action = action;
+#endif // 0
         m->action_what = w;
 
         return 0;
 }
-#endif // 0
 
 #if 0 /// elogind has its own variant in elogind-dbus.c
 int bus_manager_shutdown_or_sleep_now_or_later(