aboutsummaryrefslogtreecommitdiff
path: root/initd/supervisor.c
diff options
context:
space:
mode:
Diffstat (limited to 'initd/supervisor.c')
-rw-r--r--initd/supervisor.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/initd/supervisor.c b/initd/supervisor.c
index 8c33bf3..32a23f2 100644
--- a/initd/supervisor.c
+++ b/initd/supervisor.c
@@ -191,92 +191,3 @@ out:
target_completed(target);
return true;
}
-
-static int send_svc_list(int fd, const void *dst, size_t addrlen,
- E_SERVICE_STATE filter, E_SERVICE_STATE state,
- service_t *list)
-{
- if (filter != ESS_NONE && filter != state)
- return 0;
-
- 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,
- E_SERVICE_STATE filter)
-{
- if (send_svc_list(fd, dst, addrlen, filter, ESS_RUNNING, running))
- return;
- if (send_svc_list(fd, dst, addrlen, filter, ESS_DONE, completed))
- return;
- if (send_svc_list(fd, dst, addrlen, filter, ESS_FAILED, failed))
- return;
- if (send_svc_list(fd, dst, addrlen, filter, ESS_ENQUEUED, queue))
- return;
- if (send_svc_list(fd, dst, addrlen, filter, ESS_ENQUEUED, terminated))
- return;
- 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->next = 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;
- svc->flags &= ~SVC_FLAG_ADMIN_STOPPED;
- svc->next = queue;
- queue = svc;
-}
-
-void supervisor_stop(int id)
-{
- service_t *svc;
-
- for (svc = running; svc != NULL; svc = svc->next) {
- if (svc->id == id)
- break;
- }
-
- if (svc != NULL) {
- /* TODO: something more sophisticated? */
- svc->flags |= SVC_FLAG_ADMIN_STOPPED;
- kill(svc->pid, SIGTERM);
- }
-}