diff options
Diffstat (limited to 'src/comp.c')
-rw-r--r-- | src/comp.c | 87 |
1 files changed, 57 insertions, 30 deletions
@@ -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 */ | ||
30 | static int loaded; | ||
31 | |||
27 | static struct complist comp_list[2]; | 32 | static struct complist comp_list[2]; |
@@ -34,3 +39,3 @@ static pies_depmap_t depmap; | |||
34 | 39 | ||
35 | static int | 40 | static inline int |
36 | next_index (void) | 41 | next_index (void) |
@@ -40,3 +45,3 @@ next_index (void) | |||
40 | 45 | ||
41 | static int | 46 | static inline int |
42 | prev_index (void) | 47 | prev_index (void) |
@@ -87,2 +92,18 @@ component_append (struct component *comp) | |||
87 | void | 92 | void |
93 | comp_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 | |||
108 | void | ||
88 | component_unlink (struct component *comp) | 109 | component_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) | |||
427 | void | 453 | void |
428 | comp_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 | |||
438 | void | ||
439 | component_build_depmap (void) | 454 | component_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 | } |