mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00:00
Fix #414: zebra immediately restarts if manually stopped
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
a8433fcb7f
commit
dfaf351da1
2 files changed
+11
-1
No files matched your search
+10
-1
@@ -66,6 +66,7 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
|||||||
char cond[MAX_COND_LEN];
|
char cond[MAX_COND_LEN];
|
||||||
char fn[PATH_MAX];
|
char fn[PATH_MAX];
|
||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
|
char *nm;
|
||||||
|
|
||||||
paste(fn, sizeof(fn), dir, name);
|
paste(fn, sizeof(fn), dir, name);
|
||||||
if (fnmatch("*\\.pid", fn, 0) && fnmatch("*/pid", fn, 0))
|
if (fnmatch("*\\.pid", fn, 0) && fnmatch("*/pid", fn, 0))
|
||||||
@@ -79,9 +80,16 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg("Found svc %s for %s with pid %d", svc_ident(svc, NULL, 0), fn, svc->pid);
|
/* Service condistion to set/clear */
|
||||||
mkcond(svc, cond, sizeof(cond));
|
mkcond(svc, cond, sizeof(cond));
|
||||||
|
|
||||||
|
nm = svc_ident(svc, NULL, 0);
|
||||||
|
dbg("Found svc %s for %s with pid %d", nm, fn, svc->pid);
|
||||||
|
if (svc_is_stopping(svc)) {
|
||||||
|
dbg("Ignoring pidfile death rattles while service %s is %s", nm, svc_status(svc));
|
||||||
|
goto sneaky_zebra;
|
||||||
|
}
|
||||||
|
|
||||||
if (mask & (IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) {
|
if (mask & (IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) {
|
||||||
/*
|
/*
|
||||||
* only mark native services as started, the s6 and
|
* only mark native services as started, the s6 and
|
||||||
@@ -125,6 +133,7 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
|||||||
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
|
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
|
||||||
service_ready(svc, 1);
|
service_ready(svc, 1);
|
||||||
} else if (mask & IN_DELETE) {
|
} else if (mask & IN_DELETE) {
|
||||||
|
sneaky_zebra:
|
||||||
cond_clear(cond);
|
cond_clear(cond);
|
||||||
if (svc->notify == SVC_NOTIFY_PID)
|
if (svc->notify == SVC_NOTIFY_PID)
|
||||||
service_ready(svc, 0);
|
service_ready(svc, 0);
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ static inline void svc_starting (svc_t *svc) { if (svc) svc->starting = 1;
|
|||||||
static inline void svc_started (svc_t *svc) { if (svc) svc->starting = 0; }
|
static inline void svc_started (svc_t *svc) { if (svc) svc->starting = 0; }
|
||||||
static inline int svc_is_starting (svc_t *svc) { return svc && 0 != svc->starting; }
|
static inline int svc_is_starting (svc_t *svc) { return svc && 0 != svc->starting; }
|
||||||
static inline int svc_is_running (svc_t *svc) { return svc && svc->state == SVC_RUNNING_STATE; }
|
static inline int svc_is_running (svc_t *svc) { return svc && svc->state == SVC_RUNNING_STATE; }
|
||||||
|
static inline int svc_is_stopping (svc_t *svc) { return svc && svc->state == SVC_STOPPING_STATE; }
|
||||||
|
|
||||||
static inline int svc_is_removed (svc_t *svc) { return svc && svc->removed; }
|
static inline int svc_is_removed (svc_t *svc) { return svc && svc->removed; }
|
||||||
static inline int svc_is_changed (svc_t *svc) { return svc && 0 != svc->dirty; }
|
static inline int svc_is_changed (svc_t *svc) { return svc && 0 != svc->dirty; }
|
||||||
|
|||||||
Reference in new issue
Block a user