Welcome to little lamb

Code » anopa » commit 9ee8055

reset: Announce when skipping services

author Olivier Brunel
2018-01-27 14:53:10 UTC
committer Olivier Brunel
2018-01-28 14:47:32 UTC
parent ef3bb9da6609c5a221a4a82e598f52d604bfe2a9

reset: Announce when skipping services

If a service is starting/stopping, it was silently skipped. Now print
out a warning about it, and also include it in the return code.

doc/anopa-rc.pod +7 -7
src/anopa/aa-reset.c +7 -0
src/anopa/common.h +1 -1

diff --git a/doc/anopa-rc.pod b/doc/anopa-rc.pod
index 37dbfa7..b366f4f 100644
--- a/doc/anopa-rc.pod
+++ b/doc/anopa-rc.pod
@@ -45,19 +45,19 @@ B<aa-reset>(1)), the remaining 7bit integer is actually a bitwise combination
 of the following flags :
 
     +------+------+-------------------------------------------+----------------+
-    |  RC  | 7bit | Meaning                                   | Notes          |
+    |  RC  | 7bit | Meaning                                   | Applies to:    |
     | flag | flag |                                           |                |
     +------+------+-------------------------------------------+----------------+
-    |   2  |    1 | At least one service was unknown          |                |
+    |   2  |    1 | At least one service was unknown          | All            |
     +------+------+-------------------------------------------+----------------+
-    |   4  |    2 | At least one service was skipped          | aa-start only  |
+    |   4  |    2 | At least one service was skipped          | start/reset    |
     +------+------+-------------------------------------------+----------------+
-    |   8  |    4 | At least one service failed               |                |
+    |   8  |    4 | At least one service failed               | All            |
     +------+------+-------------------------------------------+----------------+
-    |  16  |    8 | At least one failed service was essential | aa-start only  |
+    |  16  |    8 | At least one failed service was essential | start          |
     +------+------+-------------------------------------------+----------------+
-    |  32  |   16 | At least one file copy failed (--set-*)   | aa-enable only |
+    |  32  |   16 | At least one file copy failed (--set-*)   | enable         |
     +------+------+-------------------------------------------+----------------+
-    |  64  |   32 | Failed to alarm s6-svscan                 | aa-enable only |
+    |  64  |   32 | Failed to alarm s6-svscan                 | enable         |
     +------+------+-------------------------------------------+----------------+
 
diff --git a/src/anopa/aa-reset.c b/src/anopa/aa-reset.c
index 7250184..95ea5df 100644
--- a/src/anopa/aa-reset.c
+++ b/src/anopa/aa-reset.c
@@ -96,7 +96,14 @@ reset_service (const char *name, intptr_t mode)
 
     /* Starting/Stopping cannot be reset */
     if (s->st.event == AA_EVT_STARTING || s->st.event == AA_EVT_STOPPING)
+    {
+        aa_put_warn (name, "Service is ", 0);
+        aa_bs (AA_ERR, (s->st.event == AA_EVT_STARTING) ? "starting" : "stopping");
+        aa_bs (AA_ERR, "; Skipping...");
+        aa_end_warn ();
+        rc |= RC_ST_SKIPPED;
         return;
+    }
 
     if (mode == MODE_AUTO)
     {
diff --git a/src/anopa/common.h b/src/anopa/common.h
index 2881539..dcbdf16 100644
--- a/src/anopa/common.h
+++ b/src/anopa/common.h
@@ -30,7 +30,7 @@
 enum
 {
     RC_ST_UNKNOWN       = 1 << 1,   /* at least 1 service unknown */
-    RC_ST_SKIPPED       = 1 << 2,   /* at least 1 service skipped (start) */
+    RC_ST_SKIPPED       = 1 << 2,   /* at least 1 service skipped (start/reset) */
     RC_ST_FAILED        = 1 << 3,   /* at least 1 service failed */
     RC_ST_ESSENTIAL     = 1 << 4,   /* at least 1 failed service was essential (start) */
     /* enable only: */