diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-24 13:51:39 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-24 14:08:17 +0300 |
commit | 2ba31eb953d18bb818a87caddcbca80bc8a1d37d (patch) | |
tree | 402aa4fbf3c65c2dea874f48ade2f74f5f863558 | |
parent | 6dd0ec08db301984b8f8f9082f28006d5915c183 (diff) | |
download | pies-2ba31eb953d18bb818a87caddcbca80bc8a1d37d.tar.gz pies-2ba31eb953d18bb818a87caddcbca80bc8a1d37d.tar.bz2 |
Don't remove finished startup components. Just mark them with status_finished.
* src/ctl.c (pies_comp_mode_str): Add pies_comp_startup
and pies_comp_shutdown.
* src/piesctl.c (mode_trans): Likewise.
* src/progman.c (progman_startup_phase): Test the status of
pies_comp_startup components.
(progman_waiting_p): Test status instead of pid>0 to select running
components.
(progman_cleanup): Set status of the finished startup
component to status_finished, instead of removing it.
* src/comp.c (loaded): Remove unused variable.
(component_config_commit): Remove special handling for pies_comp_startup.
-rw-r--r-- | src/comp.c | 41 | ||||
-rw-r--r-- | src/ctl.c | 4 | ||||
-rw-r--r-- | src/piesctl.c | 4 | ||||
-rw-r--r-- | src/prog.h | 2 | ||||
-rw-r--r-- | src/progman.c | 19 |
5 files changed, 26 insertions, 44 deletions
@@ -26,7 +26,2 @@ 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 | |||
32 | static struct complist comp_list[2]; | 27 | static struct complist comp_list[2]; |
@@ -542,31 +537,17 @@ component_config_commit (void) | |||
542 | /* Rearrange components, registering entries for the new ones */ | 537 | /* Rearrange components, registering entries for the new ones */ |
543 | for (comp = list->head, i = 0; comp; ) | 538 | for (comp = list->head, i = 0; comp; comp = comp->next, i++) |
544 | { | 539 | { |
545 | struct component *next = comp->next; | 540 | match = complist_find_match (prev, comp); |
546 | if (loaded && comp->mode == pies_comp_startup) | 541 | if (match) |
547 | { | 542 | { |
548 | /* Ignore startup components */ | 543 | component_merge (match, comp); |
549 | component_unlink (comp); | 544 | component_unlink (match); |
545 | match->listidx = cur; | ||
546 | component_link (match, comp->prev); | ||
550 | component_free (comp); | 547 | component_free (comp); |
548 | comp = match; | ||
551 | } | 549 | } |
552 | else | 550 | comp_array[i] = comp; |
553 | { | 551 | comp->arridx = i; |
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; | ||
569 | } | 552 | } |
570 | /* Adjust comp_count */ | ||
571 | comp_count = i; | ||
572 | 553 | ||
@@ -587,4 +568,2 @@ component_config_commit (void) | |||
587 | register_prog (comp); | 568 | register_prog (comp); |
588 | |||
589 | loaded = 1; | ||
590 | } | 569 | } |
@@ -1455,3 +1455,5 @@ static char * const pies_comp_mode_str[] = { | |||
1455 | [pies_comp_inetd] = "inetd", | 1455 | [pies_comp_inetd] = "inetd", |
1456 | [pies_comp_pass_fd] = "pass_fd", | 1456 | [pies_comp_pass_fd] = "pass_fd", |
1457 | [pies_comp_startup] = "startup", | ||
1458 | [pies_comp_shutdown] = "shutdown", | ||
1457 | [pies_comp_wait] = "wait", | 1459 | [pies_comp_wait] = "wait", |
diff --git a/src/piesctl.c b/src/piesctl.c index f2e774b..0cd2736 100644 --- a/src/piesctl.c +++ b/src/piesctl.c | |||
@@ -1054,3 +1054,5 @@ struct kwtrans mode_trans[] = { | |||
1054 | { "inetd", 'I' }, | 1054 | { "inetd", 'I' }, |
1055 | { "pass_fd", 'P' }, | 1055 | { "pass_fd", 'P' }, |
1056 | { "startup", 'S' }, | ||
1057 | { "shutdown", 'E' }, | ||
1056 | { "wait", 'W' }, | 1058 | { "wait", 'W' }, |
@@ -31,3 +31,3 @@ enum prog_status | |||
31 | status_stopping, /* Component is being stopped */ | 31 | status_stopping, /* Component is being stopped */ |
32 | status_finished, /* A "once" component has finished */ | 32 | status_finished, /* A "once" or "startup" component has finished */ |
33 | }; | 33 | }; |
diff --git a/src/progman.c b/src/progman.c index 5bc4eb3..a625885 100644 --- a/src/progman.c +++ b/src/progman.c | |||
@@ -326,3 +326,4 @@ progman_startup_phase (void) | |||
326 | { | 326 | { |
327 | if (IS_COMPONENT (prog) && prog->v.p.comp->mode == pies_comp_startup) | 327 | if (IS_COMPONENT (prog) && prog->v.p.comp->mode == pies_comp_startup |
328 | && prog->v.p.status == status_running) | ||
328 | return 1; | 329 | return 1; |
@@ -340,3 +341,3 @@ progman_waiting_p (void) | |||
340 | if (IS_COMPONENT (prog) | 341 | if (IS_COMPONENT (prog) |
341 | && prog->pid > 0 | 342 | && prog->v.p.status == status_running |
342 | && (prog->wait || prog->v.p.comp->mode == pies_comp_startup)) | 343 | && (prog->wait || prog->v.p.comp->mode == pies_comp_startup)) |
@@ -2358,10 +2359,2 @@ progman_cleanup (int expect_term) | |||
2358 | } | 2359 | } |
2359 | else if (prog->v.p.comp->mode == pies_comp_startup) | ||
2360 | { | ||
2361 | debug (1, (_("removing startup component %s, pid=%lu"), | ||
2362 | prog_tag (prog), (unsigned long)pid)); | ||
2363 | destroy_prog (&prog); | ||
2364 | if (!progman_startup_phase ()) | ||
2365 | pies_schedule_children (PIES_CHLD_WAKEUP); | ||
2366 | } | ||
2367 | else | 2360 | else |
@@ -2381,2 +2374,8 @@ progman_cleanup (int expect_term) | |||
2381 | } | 2374 | } |
2375 | else if (prog->v.p.comp->mode == pies_comp_startup) | ||
2376 | { | ||
2377 | prog->v.p.status = status_finished; | ||
2378 | if (!progman_startup_phase ()) | ||
2379 | pies_schedule_children (PIES_CHLD_WAKEUP); | ||
2380 | } | ||
2382 | else | 2381 | else |