diff options
-rw-r--r-- | src/comp.c | 27 | ||||
-rw-r--r-- | src/pies.c | 2 | ||||
-rw-r--r-- | src/progman.c | 22 | ||||
-rw-r--r-- | src/sysvinit.c | 23 |
4 files changed, 48 insertions, 26 deletions
@@ -45,22 +45,20 @@ prev_index (void) } void -component_link (struct component *comp, struct component *ref, int before) +component_link (struct component *comp, struct component *ref) { if (!ref) { struct complist *list = &comp_list[comp->listidx]; - comp->next = NULL; - comp->prev = list->tail; - if (list->tail) - list->tail->next = comp; + comp->prev = NULL; + comp->next = list->head; + if (list->head) + list->head->prev = comp; else - list->head = comp; - list->tail = comp; + list->tail = comp; + list->head = comp; } - else if (before) - component_link (comp, ref->prev, 0); else { struct complist *list = &comp_list[comp->listidx]; @@ -81,6 +79,12 @@ component_link (struct component *comp, struct component *ref, int before) } void +component_append (struct component *comp) +{ + component_link (comp, comp_list[comp->listidx].tail); +} + +void component_unlink (struct component *comp) { struct complist *list = &comp_list[comp->listidx]; @@ -132,7 +136,7 @@ component_create (const char *name) comp->redir[RETR_OUT].type = comp->redir[RETR_ERR].type = redir_null; comp->tag = grecs_strdup (name); comp->socket_type = SOCK_STREAM; - component_link (comp, NULL, 0); + component_append (comp); } return comp; } @@ -164,7 +168,6 @@ component_free (struct component *comp) pies_privs_free (&comp->privs); free (comp->runlevels); free_limits (comp->limits); - free (comp->runlevels); free (comp->service); pies_url_destroy (&comp->socket_url); free (comp->pass_fd_socket); @@ -487,7 +490,7 @@ component_config_commit (void) component_merge (match, comp); component_unlink (match); match->listidx = cur; - component_link (match, comp, 1); + component_link (match, comp->prev); component_free (comp); comp = match; } @@ -1535,6 +1535,8 @@ pies_reload (void) if (rc == 0) { component_config_commit (); + if (init_process) + sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL); progman_create_sockets (); progman_start (); } diff --git a/src/progman.c b/src/progman.c index 4f63d9a..3bbd8b3 100644 --- a/src/progman.c +++ b/src/progman.c @@ -2362,7 +2362,9 @@ progman_stop_component (struct prog *prog) break; case status_disabled: - if (!(prog->v.p.comp->flags & CF_DISABLED)) + if (!component_is_active (prog->v.p.comp)) + destroy_prog (&prog); + else if (!(prog->v.p.comp->flags & CF_DISABLED)) { logmsg (LOG_INFO, _("enabling component `%s'"), prog_tag (prog)); prog->v.p.status = status_enabled; @@ -2370,14 +2372,22 @@ progman_stop_component (struct prog *prog) break; case status_sleeping: - logmsg (LOG_INFO, _("waking up component `%s'"), prog_tag (prog)); - prog->v.p.failcount = 0; + if (!component_is_active (prog->v.p.comp)) + destroy_prog (&prog); + else + { + logmsg (LOG_INFO, _("waking up component `%s'"), prog_tag (prog)); + prog->v.p.failcount = 0; + } break; default: - logmsg (LOG_INFO, - _("stopping component `%s': component not started"), - prog_tag (prog)); + if (!component_is_active (prog->v.p.comp)) + destroy_prog (&prog); + else + logmsg (LOG_INFO, + _("stopping component `%s': component not started"), + prog_tag (prog)); } } } diff --git a/src/sysvinit.c b/src/sysvinit.c index a4e0d63..d8b7cc5 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -447,13 +447,21 @@ sysvinit_fifo_handler (int fd, void *data) { case INIT_CMD_RUNLVL: buf.req.runlevel = toupper (buf.req.runlevel); - if (buf.req.runlevel != runlevel) - { - progman_stop (); - dfl_level = buf.req.runlevel; - inittrans (); - } - break; + pies_schedule_action (ACTION_RELOAD); + switch (buf.req.runlevel) + { + case 'Q': + break; + + default: + if (buf.req.runlevel != runlevel) + { + progman_stop (); + dfl_level = buf.req.runlevel; + inittrans (); + } + } + break; case INIT_CMD_SETENV: sysvinit_setenv (buf.req.data, sizeof (buf.req.data)); @@ -562,7 +570,6 @@ sysvinit_sigtrans (int sig, int *pact) break; case SIGTERM: case SIGQUIT: - case SIGHUP: /* Ignore these signals. */ *pact = ACTION_CONT; break; |