summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/manager.c9
-rw-r--r--src/socket.c2
-rw-r--r--src/unit.c14
-rw-r--r--src/unit.h2
4 files changed, 18 insertions, 9 deletions
diff --git a/src/manager.c b/src/manager.c
index ff1c70b484..e2f13b20ec 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -2591,17 +2591,10 @@ bool manager_unit_pending_inactive(Manager *m, const char *name) {
assert(name);
/* Returns true if the unit is inactive or going down */
-
if (!(u = manager_get_unit(m, name)))
return true;
- if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)))
- return true;
-
- if (u->meta.job && u->meta.job->type == JOB_STOP)
- return true;
-
- return false;
+ return unit_pending_inactive(u);
}
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
diff --git a/src/socket.c b/src/socket.c
index fd975fd99b..34068b9192 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1167,7 +1167,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 (s->meta.job && s->meta.job->type == JOB_STOP) {
+ if (unit_pending_inactive(UNIT(s))) {
if (cfd >= 0)
close_nointr_nofail(cfd);
else {
diff --git a/src/unit.c b/src/unit.c
index bca4d97993..d5ed5e1421 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -2125,6 +2125,20 @@ Unit *unit_following(Unit *u) {
return NULL;
}
+bool unit_pending_inactive(Unit *u) {
+ assert(u);
+
+ /* Returns true if the unit is inactive or going down */
+
+ if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)))
+ return true;
+
+ if (u->meta.job && u->meta.job->type == JOB_STOP)
+ return true;
+
+ return false;
+}
+
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
diff --git a/src/unit.h b/src/unit.h
index 15e7fedd0e..c85d968b80 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -499,6 +499,8 @@ void unit_reset_failed(Unit *u);
Unit *unit_following(Unit *u);
+bool unit_pending_inactive(Unit *u);
+
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);