aboutsummaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c87
1 files changed, 57 insertions, 30 deletions
diff --git a/src/comp.c b/src/comp.c
index c3e998a..2346306 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -26,2 +26,7 @@ struct complist
26 26
27/* 0 on the first load, and 1 on all subsequent reloads. Tells the
28 component_config_commit whether we're starting from scratch or just
29 updating an already loaded configuration */
30static int loaded;
31
27static struct complist comp_list[2]; 32static struct complist comp_list[2];
@@ -34,3 +39,3 @@ static pies_depmap_t depmap;
34 39
35static int 40static inline int
36next_index (void) 41next_index (void)
@@ -40,3 +45,3 @@ next_index (void)
40 45
41static int 46static inline int
42prev_index (void) 47prev_index (void)
@@ -87,2 +92,18 @@ component_append (struct component *comp)
87void 92void
93comp_array_remove (size_t i)
94{
95 struct component *comp = comp_array[i];
96
97 depmap_remove (depmap, i);
98 while (i < comp_count -1)
99 {
100 comp_array[i] = comp_array[i+1];
101 comp_array[i]->arridx = i;
102 i++;
103 }
104 component_free (comp);
105 comp_count--;
106}
107
108void
88component_unlink (struct component *comp) 109component_unlink (struct component *comp)
@@ -203,3 +224,8 @@ component_ref_decr (struct component *comp)
203 if (--comp->ref_count == 0) 224 if (--comp->ref_count == 0)
204 component_free (comp); 225 {
226 if (component_is_active (comp))
227 comp_array_remove (comp->arridx);
228 else
229 component_free (comp);
230 }
205} 231}
@@ -427,13 +453,2 @@ report_cyclic_dependency (pies_depmap_t dp, size_t idx)
427void 453void
428comp_array_remove (size_t i)
429{
430 struct component *comp = comp_array[i];
431 if (i < comp_count - 1)
432 memmove (&comp_array[i], &comp_array[i+1],
433 (comp_count - i - 1) * sizeof comp_array[0]);
434 component_free (comp);
435 comp_count--;
436}
437
438void
439component_build_depmap (void) 454component_build_depmap (void)
@@ -462,3 +477,2 @@ component_build_depmap (void)
462 comp_array_remove (i); 477 comp_array_remove (i);
463 depmap_remove (depmap, i);
464 continue; 478 continue;
@@ -499,6 +513,3 @@ component_build_depmap (void)
499 if (comp_array[i]->flags & CF_REMOVE) 513 if (comp_array[i]->flags & CF_REMOVE)
500 { 514 comp_array_remove (i);
501 comp_array_remove (i);
502 depmap_remove (depmap, i);
503 }
504 else 515 else
@@ -530,18 +541,32 @@ component_config_commit (void)
530 541
531 /* Rearrange components, registering prog entries for the new ones */ 542 /* Rearrange components, registering entries for the new ones */
532 for (comp = list->head, i = 0; comp; comp = comp->next, i++) 543 for (comp = list->head, i = 0; comp; )
533 { 544 {
534 match = complist_find_match (prev, comp); 545 struct component *next = comp->next;
535 if (match) 546 if (loaded && comp->mode == pies_comp_startup)
536 { 547 {
537 component_merge (match, comp); 548 /* Ignore startup components */
538 component_unlink (match); 549 component_unlink (comp);
539 match->listidx = cur;
540 component_link (match, comp->prev);
541 component_free (comp); 550 component_free (comp);
542 comp = match;
543 } 551 }
544 comp_array[i] = comp; 552 else
545 comp->arridx = i; 553 {
554 match = complist_find_match (prev, comp);
555 if (match)
556 {
557 component_merge (match, comp);
558 component_unlink (match);
559 match->listidx = cur;
560 component_link (match, comp->prev);
561 component_free (comp);
562 comp = match;
563 }
564 comp_array[i] = comp;
565 comp->arridx = i;
566 i++;
567 }
568 comp = next;
546 } 569 }
570 /* Adjust comp_count */
571 comp_count = i;
547 572
@@ -562,2 +587,4 @@ component_config_commit (void)
562 register_prog (comp); 587 register_prog (comp);
588
589 loaded = 1;
563} 590}

Return to:

Send suggestions and report system problems to the System administrator.