Merge pull request #160 from troglobit/release

Forward port dirty vs enabled fixes from release branch
This commit is contained in:
Joachim Wiberg authored and GitHub committed 2021-03-19 17:23:36 +01:00
commit 4170a61d0b
3 files changed
+13 -4

No files matched your search

+2
View File
@@ -1175,6 +1175,8 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
else else
svc_mark_clean(svc); svc_mark_clean(svc);
svc_enable(svc);
/* for finit native services only, e.g. plugins/hotplug.c */ /* for finit native services only, e.g. plugins/hotplug.c */
if (!file) if (!file)
svc->protect = 1; svc->protect = 1;
+7 -2
View File
@@ -458,7 +458,7 @@ void svc_mark_dynamic(void)
if (svc->protect) if (svc->protect)
continue; continue;
*((int *)&svc->dirty) = -1; *((int *)&svc->removed) = 1;
} }
} }
@@ -472,6 +472,11 @@ void svc_mark_clean(svc_t *svc)
*((int *)&svc->dirty) = 0; *((int *)&svc->dirty) = 0;
} }
void svc_enable(svc_t *svc)
{
*((int *)&svc->removed) = 0;
}
/** /**
* svc_clean_dynamic - Stop and cleanup stale services removed from /etc/finit.d * svc_clean_dynamic - Stop and cleanup stale services removed from /etc/finit.d
* @cb: Callback to run for each stale service * @cb: Callback to run for each stale service
@@ -484,7 +489,7 @@ void svc_clean_dynamic(void (*cb)(svc_t *))
svc_t *svc, *iter = NULL; svc_t *svc, *iter = NULL;
for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) { for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) {
if (svc->dirty == -1 && cb) if (svc->removed && cb)
cb(svc); cb(svc);
} }
} }
+4 -2
View File
@@ -106,7 +106,8 @@ typedef struct svc {
const svc_state_t state; /* Paused, Reloading, Restart, Running, ... */ const svc_state_t state; /* Paused, Reloading, Restart, Running, ... */
svc_type_t type; /* Service, run, task, ... */ svc_type_t type; /* Service, run, task, ... */
int protect; /* Services like dbus-daemon & udev by Finit */ int protect; /* Services like dbus-daemon & udev by Finit */
const int dirty; /* -1: removal, 0: unmodified, 1: modified */ const int dirty; /* 0: unmodified, 1: modified */
const int removed;
int starting; /* ... waiting for pidfile to be re-asserted */ int starting; /* ... waiting for pidfile to be re-asserted */
int runlevels; int runlevels;
int sighup; /* This service supports SIGHUP :) */ int sighup; /* This service supports SIGHUP :) */
@@ -179,6 +180,7 @@ void svc_clean_dynamic (void (*cb)(svc_t *));
int svc_clean_bootstrap (svc_t *svc); int svc_clean_bootstrap (svc_t *svc);
void svc_prune_bootstrap (void); void svc_prune_bootstrap (void);
void svc_enable (svc_t *svc);
int svc_enabled (svc_t *svc); int svc_enabled (svc_t *svc);
int svc_is_unique (svc_t *svc); int svc_is_unique (svc_t *svc);
@@ -197,7 +199,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_removed (svc_t *svc) { return svc && -1 == svc->dirty; } 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; }
static inline int svc_is_updated (svc_t *svc) { return svc && 1 == svc->dirty; } static inline int svc_is_updated (svc_t *svc) { return svc && 1 == svc->dirty; }