aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-24 13:51:39 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-24 14:08:17 +0300
commit2ba31eb953d18bb818a87caddcbca80bc8a1d37d (patch)
tree402aa4fbf3c65c2dea874f48ade2f74f5f863558 /src
parent6dd0ec08db301984b8f8f9082f28006d5915c183 (diff)
downloadpies-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.
Diffstat (limited to 'src')
-rw-r--r--src/comp.c41
-rw-r--r--src/ctl.c4
-rw-r--r--src/piesctl.c4
-rw-r--r--src/prog.h2
-rw-r--r--src/progman.c19
5 files changed, 26 insertions, 44 deletions
diff --git a/src/comp.c b/src/comp.c
index 2346306..25f2657 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -26,7 +26,2 @@ struct complist
-/* 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];
@@ -542,31 +537,17 @@ component_config_commit (void)
/* 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;
@@ -587,4 +568,2 @@ component_config_commit (void)
register_prog (comp);
-
- loaded = 1;
}
diff --git a/src/ctl.c b/src/ctl.c
index a78cdbf..d9a8998 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1455,3 +1455,5 @@ static char * const pies_comp_mode_str[] = {
[pies_comp_inetd] = "inetd",
- [pies_comp_pass_fd] = "pass_fd",
+ [pies_comp_pass_fd] = "pass_fd",
+ [pies_comp_startup] = "startup",
+ [pies_comp_shutdown] = "shutdown",
[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[] = {
{ "inetd", 'I' },
- { "pass_fd", 'P' },
+ { "pass_fd", 'P' },
+ { "startup", 'S' },
+ { "shutdown", 'E' },
{ "wait", 'W' },
diff --git a/src/prog.h b/src/prog.h
index 9a3960f..04cf3d0 100644
--- a/src/prog.h
+++ b/src/prog.h
@@ -31,3 +31,3 @@ enum prog_status
status_stopping, /* Component is being stopped */
- status_finished, /* A "once" component has finished */
+ status_finished, /* A "once" or "startup" component has finished */
};
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)
{
- if (IS_COMPONENT (prog) && prog->v.p.comp->mode == pies_comp_startup)
+ if (IS_COMPONENT (prog) && prog->v.p.comp->mode == pies_comp_startup
+ && prog->v.p.status == status_running)
return 1;
@@ -340,3 +341,3 @@ progman_waiting_p (void)
if (IS_COMPONENT (prog)
- && prog->pid > 0
+ && prog->v.p.status == status_running
&& (prog->wait || prog->v.p.comp->mode == pies_comp_startup))
@@ -2358,10 +2359,2 @@ progman_cleanup (int expect_term)
}
- else if (prog->v.p.comp->mode == pies_comp_startup)
- {
- debug (1, (_("removing startup component %s, pid=%lu"),
- prog_tag (prog), (unsigned long)pid));
- destroy_prog (&prog);
- if (!progman_startup_phase ())
- pies_schedule_children (PIES_CHLD_WAKEUP);
- }
else
@@ -2381,2 +2374,8 @@ progman_cleanup (int expect_term)
}
+ else if (prog->v.p.comp->mode == pies_comp_startup)
+ {
+ prog->v.p.status = status_finished;
+ if (!progman_startup_phase ())
+ pies_schedule_children (PIES_CHLD_WAKEUP);
+ }
else

Return to:

Send suggestions and report system problems to the System administrator.