mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
Do not ignore updated services when cleaning up removed ones
When cleaning up removed services, the assumption was made that if a service was not 'removed', it was 'clean'. In reality, it could also be 'updated', which was then overwritten, causing services not being restarted. Don't do that. As a future precaution, make the dirty field const, only allowing updates from accessor methods.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user