diff options
author | David Oberhollenzer <goliath@infraroot.at> | 2019-03-18 14:08:17 +0100 |
---|---|---|
committer | David Oberhollenzer <goliath@infraroot.at> | 2019-03-18 18:29:02 +0100 |
commit | 40ad83dc6a95791bd20e214d2eb1b135900d47cc (patch) | |
tree | 90bd2364af9ce744c0b2bf7a8d58d4415e0d9fa9 /initd/supervisor.c | |
parent | 23b713c3b5345c6df187cd494bac4ef20669c1cf (diff) |
initd: implement handling of socket requests
Actually process requests and send an answer to status inquiries.
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'initd/supervisor.c')
-rw-r--r-- | initd/supervisor.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/initd/supervisor.c b/initd/supervisor.c index 3ed0ec7..3743ad6 100644 --- a/initd/supervisor.c +++ b/initd/supervisor.c @@ -167,3 +167,29 @@ bool supervisor_process_queues(void) target_completed(target); return true; } + +static int send_svc_list(int fd, const void *dst, size_t addrlen, + E_SERVICE_STATE state, service_t *list) +{ + while (list != NULL) { + if (init_socket_send_status(fd, dst, addrlen, state, list)) + return -1; + + list = list->next; + } + + return 0; +} + +void supervisor_answer_status_request(int fd, const void *dst, size_t addrlen) +{ + if (send_svc_list(fd, dst, addrlen, ESS_RUNNING, running)) + return; + if (send_svc_list(fd, dst, addrlen, ESS_EXITED, completed)) + return; + if (send_svc_list(fd, dst, addrlen, ESS_ENQUEUED, queue)) + return; + if (send_svc_list(fd, dst, addrlen, ESS_ENQUEUED, terminated)) + return; + init_socket_send_status(fd, dst, addrlen, ESS_NONE, NULL); +} |