diff --git a/plugins/pidfile.c b/plugins/pidfile.c index ef50c8cc..ff810b60 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -66,6 +66,7 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask) char cond[MAX_COND_LEN]; char fn[PATH_MAX]; svc_t *svc; + char *nm; paste(fn, sizeof(fn), dir, name); 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; } - 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)); + 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)) { /* * 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) service_ready(svc, 1); } else if (mask & IN_DELETE) { + sneaky_zebra: cond_clear(cond); if (svc->notify == SVC_NOTIFY_PID) service_ready(svc, 0); diff --git a/src/svc.h b/src/svc.h index 6c217459..d00ac14c 100644 --- a/src/svc.h +++ b/src/svc.h @@ -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 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_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_changed (svc_t *svc) { return svc && 0 != svc->dirty; }