summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/automount.c2
-rw-r--r--src/core/dbus.c4
-rw-r--r--src/core/manager.c4
-rw-r--r--src/core/manager.h2
-rw-r--r--src/core/path.c2
-rw-r--r--src/core/socket.c4
-rw-r--r--src/core/timer.c2
-rw-r--r--src/core/unit.c29
-rw-r--r--src/core/unit.h5
9 files changed, 32 insertions, 22 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index e6eedda96f..a20d5340f2 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -593,7 +593,7 @@ static void automount_enter_runnning(Automount *a) {
/* We don't take mount requests anymore if we are supposed to
* shut down anyway */
- if (unit_pending_inactive(UNIT(a))) {
+ if (unit_stop_pending(UNIT(a))) {
log_debug_unit(UNIT(a)->id,
"Suppressing automount request on %s since unit stop is scheduled.", UNIT(a)->id);
automount_send_ready(a, -EHOSTDOWN);
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 67ab1ae7f7..5a61a1a654 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -363,8 +363,8 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
log_debug("Got D-Bus activation request for %s", name);
- if (manager_unit_pending_inactive(m, SPECIAL_DBUS_SERVICE) ||
- manager_unit_pending_inactive(m, SPECIAL_DBUS_SOCKET)) {
+ if (manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SERVICE) ||
+ manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SOCKET)) {
r = -EADDRNOTAVAIL;
dbus_set_error(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down.");
} else {
diff --git a/src/core/manager.c b/src/core/manager.c
index 2265ef7173..c7f8f20a70 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2328,7 +2328,7 @@ void manager_reset_failed(Manager *m) {
unit_reset_failed(u);
}
-bool manager_unit_pending_inactive(Manager *m, const char *name) {
+bool manager_unit_inactive_or_pending(Manager *m, const char *name) {
Unit *u;
assert(m);
@@ -2339,7 +2339,7 @@ bool manager_unit_pending_inactive(Manager *m, const char *name) {
if (!u)
return true;
- return unit_pending_inactive(u);
+ return unit_inactive_or_pending(u);
}
void manager_check_finished(Manager *m) {
diff --git a/src/core/manager.h b/src/core/manager.h
index 649a8aac51..a0be2927f7 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -291,7 +291,7 @@ void manager_reset_failed(Manager *m);
void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success);
void manager_send_unit_plymouth(Manager *m, Unit *u);
-bool manager_unit_pending_inactive(Manager *m, const char *name);
+bool manager_unit_inactive_or_pending(Manager *m, const char *name);
void manager_check_finished(Manager *m);
diff --git a/src/core/path.c b/src/core/path.c
index e1330f6c95..ab1fe2eb65 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -523,7 +523,7 @@ static void path_enter_running(Path *p) {
dbus_error_init(&error);
/* Don't start job if we are supposed to go down */
- if (unit_pending_inactive(UNIT(p)))
+ if (unit_stop_pending(UNIT(p)))
return;
r = manager_add_job(UNIT(p)->manager, JOB_START, UNIT_TRIGGER(UNIT(p)),
diff --git a/src/core/socket.c b/src/core/socket.c
index 9f1af1e28f..c276afe38f 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1447,7 +1447,7 @@ static void socket_enter_running(Socket *s, int cfd) {
/* We don't take connections anymore if we are supposed to
* shut down anyway */
- if (unit_pending_inactive(UNIT(s))) {
+ if (unit_stop_pending(UNIT(s))) {
log_debug_unit(UNIT(s)->id,
"Suppressing connection request on %s since unit stop is scheduled.",
UNIT(s)->id);
@@ -1478,7 +1478,7 @@ static void socket_enter_running(Socket *s, int cfd) {
/* If there's already a start pending don't bother to
* do anything */
SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERS], i)
- if (unit_pending_active(u)) {
+ if (unit_active_or_pending(u)) {
pending = true;
break;
}
diff --git a/src/core/timer.c b/src/core/timer.c
index b8039d82ec..ff8c30583c 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -374,7 +374,7 @@ static void timer_enter_running(Timer *t) {
dbus_error_init(&error);
/* Don't start job if we are supposed to go down */
- if (unit_pending_inactive(UNIT(t)))
+ if (unit_stop_pending(UNIT(t)))
return;
r = manager_add_job(UNIT(t)->manager, JOB_START, UNIT_TRIGGER(UNIT(t)),
diff --git a/src/core/unit.c b/src/core/unit.c
index c0c3ce90a7..b4a4f8cd2e 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1206,19 +1206,19 @@ static void unit_check_unneeded(Unit *u) {
return;
SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY], i)
- if (unit_pending_active(other))
+ if (unit_active_or_pending(other))
return;
SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
- if (unit_pending_active(other))
+ if (unit_active_or_pending(other))
return;
SET_FOREACH(other, u->dependencies[UNIT_WANTED_BY], i)
- if (unit_pending_active(other))
+ if (unit_active_or_pending(other))
return;
SET_FOREACH(other, u->dependencies[UNIT_BOUND_BY], i)
- if (unit_pending_active(other))
+ if (unit_active_or_pending(other))
return;
log_info_unit(u->id, "Service %s is not needed anymore. Stopping.", u->id);
@@ -2651,21 +2651,30 @@ Unit *unit_following(Unit *u) {
return NULL;
}
-bool unit_pending_inactive(Unit *u) {
+bool unit_stop_pending(Unit *u) {
assert(u);
- /* Returns true if the unit is inactive or going down */
+ /* This call does check the current state of the unit. It's
+ * hence useful to be called from state change calls of the
+ * unit itself, where the state isn't updated yet. This is
+ * different from unit_inactive_or_pending() which checks both
+ * the current state and for a queued job. */
- if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)))
- return true;
+ return u->job && u->job->type == JOB_STOP;
+}
+
+bool unit_inactive_or_pending(Unit *u) {
+ assert(u);
+
+ /* Returns true if the unit is inactive or going down */
- if (u->job && u->job->type == JOB_STOP)
+ if (unit_stop_pending(u))
return true;
return false;
}
-bool unit_pending_active(Unit *u) {
+bool unit_active_or_pending(Unit *u) {
assert(u);
/* Returns true if the unit is active or going up */
diff --git a/src/core/unit.h b/src/core/unit.h
index 6bfe58c8bf..a086538c61 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -536,8 +536,9 @@ void unit_reset_failed(Unit *u);
Unit *unit_following(Unit *u);
-bool unit_pending_inactive(Unit *u);
-bool unit_pending_active(Unit *u);
+bool unit_stop_pending(Unit *u);
+bool unit_inactive_or_pending(Unit *u);
+bool unit_active_or_pending(Unit *u);
int unit_add_default_target_dependency(Unit *u, Unit *target);