summaryrefslogtreecommitdiff
path: root/initd
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2019-03-29 15:08:53 +0100
committerDavid Oberhollenzer <goliath@infraroot.at>2019-03-29 21:00:53 +0100
commitc1cb8491f95919428651c4d3eff59090e3f73844 (patch)
treecd303903ec30923ba0ccf730d7e672f91d56751e /initd
parentc8c0f10ce1923bb541bf80027739e205bcbde436 (diff)
fix: actually remove started service from list
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'initd')
-rw-r--r--initd/supervisor.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/initd/supervisor.c b/initd/supervisor.c
index a11c6b8..37205ef 100644
--- a/initd/supervisor.c
+++ b/initd/supervisor.c
@@ -304,19 +304,38 @@ void supervisor_answer_status_request(int fd, const void *dst, size_t addrlen,
init_socket_send_status(fd, dst, addrlen, ESS_NONE, NULL);
}
-void supervisor_start(int id)
+static service_t *remove_by_id(service_t **list, int id)
{
- service_t *svc;
+ service_t *svc = *list, *prev = NULL;
- for (svc = completed; svc != NULL; svc = svc->next) {
- if (svc->id == id)
- goto found;
+ while (svc != NULL && svc->id != id) {
+ prev = svc;
+ svc = svc->next;
}
- for (svc = failed; svc != NULL; svc = svc->next) {
- if (svc->id == id)
- goto found;
+ if (svc != NULL) {
+ if (prev == NULL) {
+ *list = svc->next;
+ } else {
+ prev = svc->next;
+ }
}
+
+ return svc;
+}
+
+void supervisor_start(int id)
+{
+ service_t *svc;
+
+ svc = remove_by_id(&completed, id);
+ if (svc != NULL)
+ goto found;
+
+ svc = remove_by_id(&failed, id);
+ if (svc != NULL)
+ goto found;
+
return;
found:
svc->rspwn_count = 0;