chiark / gitweb /
unit: unify some code
authorLennart Poettering <lennart@poettering.net>
Wed, 1 Sep 2010 01:35:04 +0000 (03:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 1 Sep 2010 01:35:04 +0000 (03:35 +0200)
src/manager.c
src/socket.c
src/unit.c
src/unit.h

index ff1c70b4845762446c80382b1051a528aa0e7962..e2f13b20ec52d2913fceac70e5f10f00b99dc237 100644 (file)
@@ -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 */
         assert(name);
 
         /* Returns true if the unit is inactive or going down */
-
         if (!(u = manager_get_unit(m, name)))
                 return true;
 
         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] = {
 }
 
 static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
index fd975fd99b92cd4d7d66da22af4b93002aeebaa0..34068b91921f0dd889ffcbffe60ca225454dd420 100644 (file)
@@ -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 */
 
         /* 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  {
                 if (cfd >= 0)
                         close_nointr_nofail(cfd);
                 else  {
index bca4d97993c9acae1411e6aed0530aaa5c1d53b2..d5ed5e1421f57624da9467b50effc1428ed98726 100644 (file)
@@ -2125,6 +2125,20 @@ Unit *unit_following(Unit *u) {
         return NULL;
 }
 
         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",
 static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
         [UNIT_STUB] = "stub",
         [UNIT_LOADED] = "loaded",
index 15e7fedd0e550a0bbd122219c4eceda22464710f..c85d968b809d5aaa4714866beeaca469ad04a797 100644 (file)
@@ -499,6 +499,8 @@ void unit_reset_failed(Unit *u);
 
 Unit *unit_following(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);
 
 const char *unit_load_state_to_string(UnitLoadState i);
 UnitLoadState unit_load_state_from_string(const char *s);