diff --git a/doc/service.md b/doc/service.md index 807403b4..943b56fe 100644 --- a/doc/service.md +++ b/doc/service.md @@ -14,8 +14,9 @@ state. The current state depends on the two following conditions: * `E`: Service enabled. In order for `E` to be satisfied, the service - must be allowed to run in the current runlevel and must not be - blocked. A service may be blocked for several reasons: + must be allowed to run in the current runlevel and not be stopped. + + A service may be stopped, or blocked, for several reasons: - The user has manually stopped the service using `initctl stop JOB` - The program exits immediately. I.e. keeps crashing (make sure to use diff --git a/src/api.c b/src/api.c index 3233c9f3..e7858563 100644 --- a/src/api.c +++ b/src/api.c @@ -49,23 +49,23 @@ static int call(int (*action)(svc_t *), char *buf, size_t len) return svc_parse_jobstr(buf, len, action, NULL); } -static int service_block(svc_t *svc) +static int service_stop(svc_t *svc) { if (!svc) return 1; - svc_block(svc); + svc_stop(svc); service_step(svc); return 0; } -static int service_unblock(svc_t *svc) +static int service_start(svc_t *svc) { if (!svc) return 1; - svc_unblock(svc); + svc_start(svc); service_step(svc); return 0; @@ -82,8 +82,8 @@ static int service_restart(svc_t *svc) return 0; } -static int do_start (char *buf, size_t len) { return call(service_unblock, buf, len); } -static int do_pause (char *buf, size_t len) { return call(service_block, buf, len); } +static int do_start (char *buf, size_t len) { return call(service_start, buf, len); } +static int do_stop (char *buf, size_t len) { return call(service_stop, buf, len); } static int do_restart(char *buf, size_t len) { return call(service_restart, buf, len); } #ifdef INETD_ENABLED @@ -240,7 +240,7 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events)) break; case INIT_CMD_STOP_SVC: - result = do_pause(rq.data, sizeof(rq.data)); + result = do_stop(rq.data, sizeof(rq.data)); break; case INIT_CMD_RESTART_SVC: diff --git a/src/svc.c b/src/svc.c index 38b8bff9..e33e9335 100644 --- a/src/svc.c +++ b/src/svc.c @@ -480,7 +480,7 @@ char *svc_status(svc_t *svc) return "crashed"; case SVC_BLOCK_USER: - return "blocked"; + return "stopped"; case SVC_BLOCK_BUSY: return "busy"; diff --git a/src/svc.h b/src/svc.h index a2e434bb..cd78ccad 100644 --- a/src/svc.h +++ b/src/svc.h @@ -92,7 +92,7 @@ typedef struct svc { int starting; /* ... waiting for pidfile to be re-asserted */ int runlevels; int sighup; /* This service supports SIGHUP :) */ - svc_block_t block; /* Reason that this service is currently blocked */ + svc_block_t block; /* Reason that this service is currently stopped */ char cond[MAX_ARG_LEN]; /* Incremented for each restart by service monitor. */ @@ -192,7 +192,8 @@ static inline int svc_is_daemon (svc_t *svc) { return svc && SVC_TYPE_SERVICE static inline int svc_is_blocked (svc_t *svc) { return svc->block != SVC_BLOCK_NONE; } static inline int svc_is_busy (svc_t *svc) { return svc->block == SVC_BLOCK_BUSY; } static inline void svc_unblock (svc_t *svc) { svc->block = SVC_BLOCK_NONE; } -static inline void svc_block (svc_t *svc) { svc->block = SVC_BLOCK_USER; } +#define svc_start(svc) svc_unblock(svc) +static inline void svc_stop (svc_t *svc) { svc->block = SVC_BLOCK_USER; } static inline void svc_busy (svc_t *svc) { svc->block = SVC_BLOCK_BUSY; } static inline void svc_missing (svc_t *svc) { svc->block = SVC_BLOCK_MISSING; } static inline void svc_restarting (svc_t *svc) { svc->block = SVC_BLOCK_RESTARTING; }