summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-06-13 08:13:23 +0200
committerSven Eden <yamakuzure@gmx.net>2018-06-29 07:12:51 +0200
commit6d68b26e0d54bfed2dbe0d3cc6251295bce243a9 (patch)
tree20f57193df547f95d2a860e289de883b878cb147 /src
parentff30424a0526b809bf40f22e6ad58601419da174 (diff)
Move delay_shutdown_or_sleep() back to logind-dbus.c
Diffstat (limited to 'src')
-rw-r--r--src/login/elogind-dbus.c35
-rw-r--r--src/login/elogind-dbus.h1
-rw-r--r--src/login/logind-dbus.c16
3 files changed, 14 insertions, 38 deletions
diff --git a/src/login/elogind-dbus.c b/src/login/elogind-dbus.c
index 818c3676e..646a4831c 100644
--- a/src/login/elogind-dbus.c
+++ b/src/login/elogind-dbus.c
@@ -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,
diff --git a/src/login/elogind-dbus.h b/src/login/elogind-dbus.h
index deac06f73..182426a0e 100644
--- a/src/login/elogind-dbus.h
+++ b/src/login/elogind-dbus.h
@@ -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);
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 3ac67a444..46d7a4f25 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -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(