diff options
Diffstat (limited to 'src/comp.c')
-rw-r--r-- | src/comp.c | 41 |
1 files changed, 10 insertions, 31 deletions
@@ -3,53 +3,48 @@ GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Pies is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */ #include "pies.h" #include "prog.h" #include <assert.h> struct complist { struct component *head; struct component *tail; }; -/* 0 on the first load, and 1 on all subsequent reloads. Tells the - component_config_commit whether we're starting from scratch or just - updating an already loaded configuration */ -static int loaded; - static struct complist comp_list[2]; static int cur; static struct component **comp_array; static size_t comp_count; static pies_depmap_t depmap; static inline int next_index (void) { return (cur + 1) % ARRAY_SIZE (comp_list); } static inline int prev_index (void) { return (cur + ARRAY_SIZE (comp_list) - 1) % ARRAY_SIZE (comp_list); } void component_link (struct component *comp, struct component *ref) { if (!ref) @@ -519,95 +514,79 @@ component_build_depmap (void) } void component_config_commit (void) { struct complist *list = &comp_list[cur]; struct component *comp, *match; int prev = prev_index (); size_t i; /* Count available components and allocate array for them */ for (comp = list->head, i = 0; comp; comp = comp->next, i++) /* nothing */; if (i == 0) { free (comp_array); comp_array = NULL; } else comp_array = grecs_realloc (comp_array, i * sizeof (comp_array[0])); comp_count = i; /* Rearrange components, registering entries for the new ones */ - for (comp = list->head, i = 0; comp; ) + for (comp = list->head, i = 0; comp; comp = comp->next, i++) { - struct component *next = comp->next; - if (loaded && comp->mode == pies_comp_startup) + match = complist_find_match (prev, comp); + if (match) { - /* Ignore startup components */ - component_unlink (comp); + component_merge (match, comp); + component_unlink (match); + match->listidx = cur; + component_link (match, comp->prev); component_free (comp); + comp = match; } - else - { - match = complist_find_match (prev, comp); - if (match) - { - component_merge (match, comp); - component_unlink (match); - match->listidx = cur; - component_link (match, comp->prev); - component_free (comp); - comp = match; - } - comp_array[i] = comp; - comp->arridx = i; - i++; - } - comp = next; + comp_array[i] = comp; + comp->arridx = i; } - /* Adjust comp_count */ - comp_count = i; /* Mark orphaned progs for termination */ list = &comp_list[prev]; if (list->head) { progman_foreach (mark_prog, NULL); pies_schedule_children (PIES_CHLD_GC); } /* 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); - - loaded = 1; } static int component_verify (struct component *comp, grecs_locus_t *locus) { int header = 0; int i; #define COMPERR(func, fmt, arg) \ do \ { \ if (!header) \ { \ grecs_warning (locus, 0, _("in component %s:"), comp->tag); \ header = 1; \ } \ func (locus, 0, fmt, arg); \ } \ while (0) if (comp->flags & CF_INTERNAL) { comp->mode = pies_comp_inetd; if (!comp->service) /* TRANSLATORS: do not translate quoted words, they are keywords. */ |