mirror of
https://github.com/troglobit/finit.git
synced 2026-11-19 19:40:50 +00:00
Assert svc condition only when PID file has been created/updated
This patch prevents too early start of services depending on other services. E.g, if service B depends on A then we must wait for A to signal that it is ready before we allow B to start -- in a Finit based system A does this by creating, or touching (updating mtime), its PID file. Services (like A) that support SIGHUP should call utime(), or utimensat(), on the PID file at the end of their SIGHUP handler. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
cef4b5761a
commit
4ae5c54f45
3 files changed
+22
-4
No files matched your search
@@ -88,6 +88,7 @@ typedef struct svc {
|
||||
time_t mtime; /* Modification time for .conf from /etc/finit.d/ */
|
||||
const int dirty; /* Set if old mtime != new mtime => reloaded,
|
||||
* or -1 when marked for removal */
|
||||
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 */
|
||||
@@ -168,6 +169,10 @@ int svc_is_unique (svc_t *svc);
|
||||
static inline int svc_in_runlevel(svc_t *svc, int runlevel) { return svc && ISSET(svc->runlevels, runlevel); }
|
||||
static inline int svc_has_sighup(svc_t *svc) { return svc && 0 != svc->sighup; }
|
||||
|
||||
static inline void svc_starting (svc_t *svc) { svc->starting = 1; }
|
||||
static inline void svc_started (svc_t *svc) { svc->starting = 0; }
|
||||
static inline int svc_is_starting(svc_t *svc) { 0 != svc->starting; }
|
||||
|
||||
static inline int svc_is_dynamic(svc_t *svc) { return svc && 0 != svc->mtime; }
|
||||
static inline int svc_is_removed(svc_t *svc) { return svc && -1 == svc->dirty; }
|
||||
static inline int svc_is_changed(svc_t *svc) { return svc && 0 != svc->dirty; }
|
||||
|
||||
Reference in new issue
Block a user