summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-05-24 10:51:39 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-05-24 11:08:17 (GMT)
commit2ba31eb953d18bb818a87caddcbca80bc8a1d37d (patch) (side-by-side diff)
tree402aa4fbf3c65c2dea874f48ade2f74f5f863558
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 (more/less context) (show whitespace changes)
-rw-r--r--src/comp.c23
-rw-r--r--src/ctl.c2
-rw-r--r--src/piesctl.c2
-rw-r--r--src/prog.h2
-rw-r--r--src/progman.c19
5 files changed, 15 insertions, 33 deletions
diff --git a/src/comp.c b/src/comp.c
index 2346306..25f2657 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -21,17 +21,12 @@
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;
@@ -537,22 +532,13 @@ component_config_commit (void)
}
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; )
- {
- struct component *next = comp->next;
- if (loaded && comp->mode == pies_comp_startup)
- {
- /* Ignore startup components */
- component_unlink (comp);
- component_free (comp);
- }
- else
+ for (comp = list->head, i = 0; comp; comp = comp->next, i++)
{
match = complist_find_match (prev, comp);
if (match)
{
component_merge (match, comp);
component_unlink (match);
@@ -560,18 +546,13 @@ component_config_commit (void)
component_link (match, comp->prev);
component_free (comp);
comp = match;
}
comp_array[i] = comp;
comp->arridx = i;
- i++;
}
- comp = next;
- }
- /* Adjust comp_count */
- comp_count = i;
/* Mark orphaned progs for termination */
list = &comp_list[prev];
if (list->head)
{
progman_foreach (mark_prog, NULL);
@@ -582,14 +563,12 @@ component_config_commit (void)
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;
diff --git a/src/ctl.c b/src/ctl.c
index a78cdbf..d9a8998 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1451,12 +1451,14 @@ static char * const pies_type_str[] = {
static char * const pies_comp_mode_str[] = {
[pies_comp_exec] = "exec",
[pies_comp_accept] = "accept",
[pies_comp_inetd] = "inetd",
[pies_comp_pass_fd] = "pass_fd",
+ [pies_comp_startup] = "startup",
+ [pies_comp_shutdown] = "shutdown",
[pies_comp_wait] = "wait",
[pies_comp_once] = "once",
[pies_comp_boot] = "boot",
[pies_comp_bootwait] = "bootwait",
[pies_comp_powerfail] = "powerfail",
[pies_comp_powerwait] = "powerwait",
diff --git a/src/piesctl.c b/src/piesctl.c
index f2e774b..0cd2736 100644
--- a/src/piesctl.c
+++ b/src/piesctl.c
@@ -1050,12 +1050,14 @@ struct kwtrans
struct kwtrans mode_trans[] = {
{ "exec", 'C' },
{ "accept", 'A' },
{ "inetd", 'I' },
{ "pass_fd", 'P' },
+ { "startup", 'S' },
+ { "shutdown", 'E' },
{ "wait", 'W' },
{ "once", 'c' },
{ "boot", 'B' },
{ "bootwait", 'w' },
{ "powerfail", 'F' },
{ "powerwait", 'f' },
diff --git a/src/prog.h b/src/prog.h
index 9a3960f..04cf3d0 100644
--- a/src/prog.h
+++ b/src/prog.h
@@ -26,13 +26,13 @@ enum prog_status
status_stopped, /* Component is stopped. */
status_running, /* Component is running */
status_listener, /* Component is an inetd listener */
status_sleeping, /* Component is sleeping. An attempt to start it will
be made at prog->v.p.timestamp + SLEEPTIME */
status_stopping, /* Component is being stopped */
- status_finished, /* A "once" component has finished */
+ status_finished, /* A "once" or "startup" component has finished */
};
struct conn_class
{
const char *tag;
union pies_sockaddr_storage sa_storage;
diff --git a/src/progman.c b/src/progman.c
index 5bc4eb3..a625885 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -321,13 +321,14 @@ static inline int
progman_startup_phase (void)
{
struct prog *prog;
for (prog = proghead; prog; prog = prog->next)
{
- 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;
}
return 0;
}
int
@@ -335,13 +336,13 @@ progman_waiting_p (void)
{
struct prog *prog;
for (prog = proghead; prog; prog = prog->next)
{
if (IS_COMPONENT (prog)
- && prog->pid > 0
+ && prog->v.p.status == status_running
&& (prog->wait || prog->v.p.comp->mode == pies_comp_startup))
{
debug (3, ("%s: waiting for %s (%lu)",
__FUNCTION__, prog_tag (prog),
(unsigned long) prog->pid));
return 1;
@@ -2353,20 +2354,12 @@ progman_cleanup (int expect_term)
react (listener, status, pid);
if (listener->v.p.comp->flags & CF_WAIT)
enable_socket (listener->v.p.socket);
}
destroy_prog (&prog);
}
- 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
{
if (prog->v.p.comp->mode >= pies_mark_sysvinit
&& prog->v.p.comp->mode != pies_comp_ondemand)
{
sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog),
@@ -2376,12 +2369,18 @@ progman_cleanup (int expect_term)
if (prog->wait)
{
pies_schedule_children (PIES_CHLD_WAKEUP);
prog->wait = 0;
}
}
+ 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
{
if (is_sysvinit (prog->v.p.comp))
sysvinit_acct (SYSV_ACCT_PROC_STOP, "",
prog_tag (prog), pid, "");

Return to:

Send suggestions and report system problems to the System administrator.