diff options
Diffstat (limited to 'src/comp.c')
-rw-r--r-- | src/comp.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -341,40 +341,46 @@ component_config_begin (void) { cur = next_index (); } void component_config_rollback (void) { struct complist *list = &comp_list[cur]; while (list->head) component_free (list->head); cur = prev_index (); } + +/* Return true if PROG is a leftover from previous configuration */ +static int +prog_is_leftover (struct prog *prog) +{ + return IS_COMPONENT (prog) && !component_is_active (prog->v.p.comp); +} +/* If PROG is a leftover, gracefully stop it and mark as disabled */ static int cb_terminate_prog (struct prog *prog, void *data) { - if (IS_COMPONENT (prog) && !component_is_active (prog->v.p.comp)) - { - progman_stop_component (prog); - prog->v.p.comp->flags |= CF_DISABLED; - } + if (prog_is_leftover (prog)) + progman_stop_component (&prog); return 0; } +/* If PROG is a leftover, slay it with SIGKILL */ static int cb_kill_prog (struct prog *prog, void *data) { - if (!(IS_COMPONENT (prog) && component_is_active (prog->v.p.comp))) + if (prog_is_leftover (prog)) prog_stop (prog, SIGKILL); return 0; } static int list_is_empty (void *p) { struct complist *list = p; return list->head == NULL; } static int @@ -500,25 +506,25 @@ component_config_commit (void) /* Terminate orphaned progs */ list = &comp_list[prev]; if (list->head) { progman_foreach (cb_terminate_prog, NULL); if (progman_wait_until (list_is_empty, list)) { progman_foreach (cb_kill_prog, NULL); progman_wait_until (list_is_empty, list); } } - + /* Build dependency map */ component_build_depmap (); /* Register new progs */ for (comp = comp_list[cur].head; comp; comp = comp->next) if (!comp->prog) register_prog (comp); } static int component_verify (struct component *comp, grecs_locus_t *locus) { |