aboutsummaryrefslogtreecommitdiff
path: root/initd
diff options
context:
space:
mode:
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;