diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-01-30 14:52:52 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-01-30 14:52:52 +0200 |
commit | 7f20aa4f7e26d8f740b55bef98f0c3c78eca0e79 (patch) | |
tree | c32e862b002c167a36f4d0f0f1fb9a2f6d626d68 | |
parent | e9379677a3c82753f0d29ef1c3490eec345db3c0 (diff) | |
download | pies-7f20aa4f7e26d8f740b55bef98f0c3c78eca0e79.tar.gz pies-7f20aa4f7e26d8f740b55bef98f0c3c78eca0e79.tar.bz2 |
Fix configuration reload and telinit q
* src/comp.c (component_link): Always link after the REF.
component. If REF is NULL, link at list head.
(component_append): New function.
(component_create): Use component_append.
(component_free): Fix double-free.
* src/pies.c (pies_reload): Call sysvinit_runlevel_setup.
* src/progman.c (progman_stop_component): Remove inactive
components.
* src/sysvinit.c (sysvinit_fifo_handler): Schedule ACTION_RELOAD.
on receiving INIT_CMD_RUNLVL.
(sysvinit_sigtrans): Don't handle SIGHUP.
-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
@@ -46,5 +46,5 @@ prev_index (void) void -component_link (struct component *comp, struct component *ref, int before) +component_link (struct component *comp, struct component *ref) { if (!ref) @@ -52,14 +52,12 @@ component_link (struct component *comp, struct component *ref, int before) 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 { @@ -82,4 +80,10 @@ 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) { @@ -133,5 +137,5 @@ component_create (const char *name) comp->tag = grecs_strdup (name); comp->socket_type = SOCK_STREAM; - component_link (comp, NULL, 0); + component_append (comp); } return comp; @@ -165,5 +169,4 @@ component_free (struct component *comp) free (comp->runlevels); free_limits (comp->limits); - free (comp->runlevels); free (comp->service); pies_url_destroy (&comp->socket_url); @@ -488,5 +491,5 @@ component_config_commit (void) component_unlink (match); match->listidx = cur; - component_link (match, comp, 1); + component_link (match, comp->prev); component_free (comp); comp = match; @@ -1536,4 +1536,6 @@ pies_reload (void) { 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 @@ -2363,5 +2363,7 @@ progman_stop_component (struct prog *prog) 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)); @@ -2371,12 +2373,20 @@ progman_stop_component (struct prog *prog) 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 @@ -448,11 +448,19 @@ 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: @@ -563,5 +571,4 @@ sysvinit_sigtrans (int sig, int *pact) case SIGTERM: case SIGQUIT: - case SIGHUP: /* Ignore these signals. */ *pact = ACTION_CONT; |