1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-22 11:19:45 +01:00

fix: actually remove started service from list

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-03-29 15:08:53 +01:00
parent c8c0f10ce1
commit c1cb8491f9

View file

@ -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); init_socket_send_status(fd, dst, addrlen, ESS_NONE, NULL);
} }
static service_t *remove_by_id(service_t **list, int id)
{
service_t *svc = *list, *prev = NULL;
while (svc != NULL && svc->id != id) {
prev = svc;
svc = svc->next;
}
if (svc != NULL) {
if (prev == NULL) {
*list = svc->next;
} else {
prev = svc->next;
}
}
return svc;
}
void supervisor_start(int id) void supervisor_start(int id)
{ {
service_t *svc; service_t *svc;
for (svc = completed; svc != NULL; svc = svc->next) { svc = remove_by_id(&completed, id);
if (svc->id == id) if (svc != NULL)
goto found; goto found;
}
svc = remove_by_id(&failed, id);
if (svc != NULL)
goto found;
for (svc = failed; svc != NULL; svc = svc->next) {
if (svc->id == id)
goto found;
}
return; return;
found: found:
svc->rspwn_count = 0; svc->rspwn_count = 0;