diff --git a/api.c b/api.c index 1569a598..03ceec34 100644 --- a/api.c +++ b/api.c @@ -130,7 +130,7 @@ static int service_unblock(svc_t *svc) static int service_restart(svc_t *svc) { - svc->dirty = 1; + svc_mark_dirty(svc); service_step(svc); return 0; } diff --git a/service.c b/service.c index 7c4dba90..ebac78a9 100644 --- a/service.c +++ b/service.c @@ -844,7 +844,7 @@ restart: break; } - svc->dirty = 0; + svc_mark_clean(svc); switch (svc->type) { case SVC_TYPE_SERVICE: @@ -898,7 +898,7 @@ restart: service_stop(svc); *state = SVC_STOPPING_STATE; } - svc->dirty = 0; + svc_mark_clean(svc); } break; diff --git a/svc.c b/svc.c index bf33393d..42589985 100644 --- a/svc.c +++ b/svc.c @@ -352,17 +352,27 @@ void svc_mark_dynamic(void) svc_t *svc = svc_dynamic_iterator(1); while (svc) { - svc->dirty = -1; + *((int *)&svc->dirty) = -1; svc = svc_dynamic_iterator(0); } } +void svc_mark_dirty(svc_t *svc) +{ + *((int *)&svc->dirty) = 1; +} + +void svc_mark_clean(svc_t *svc) +{ + *((int *)&svc->dirty) = 0; +} + void svc_check_dirty(svc_t *svc, time_t mtime) { if (svc->mtime != mtime) - svc->dirty = 1; + svc_mark_dirty(svc); else - svc->dirty = 0; + svc_mark_clean(svc); svc->mtime = mtime; } @@ -381,7 +391,6 @@ void svc_clean_dynamic(void (*cb)(svc_t *)) if (svc->dirty == -1 && cb) cb(svc); - svc->dirty = 0; svc = svc_dynamic_iterator(0); } } diff --git a/svc.h b/svc.h index be45c255..b951abc2 100644 --- a/svc.h +++ b/svc.h @@ -84,7 +84,7 @@ typedef struct svc { const svc_state_t state; /* Paused, Reloading, Restart, Running, ... */ svc_type_t type; time_t mtime; /* Modification time for .conf from /etc/finit.d/ */ - int dirty; /* Set if old mtime != new mtime => reloaded, + const int dirty; /* Set if old mtime != new mtime => reloaded, * or -1 when marked for removal */ int runlevels; int sighup; /* This service supports SIGHUP :) */ @@ -153,6 +153,8 @@ void svc_foreach_dynamic (void (*cb)(svc_t *)); void svc_mark_dynamic (void); void svc_check_dirty (svc_t *svc, time_t mtime); +void svc_mark_dirty (svc_t *svc); +void svc_mark_clean (svc_t *svc); void svc_clean_dynamic (void (*cb)(svc_t *)); int svc_clean_bootstrap (svc_t *svc);