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) (unidiff)
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) (ignore whitespace changes)
-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
@@ -21,17 +21,12 @@
21struct complist 21struct complist
22{ 22{
23 struct component *head; 23 struct component *head;
24 struct component *tail; 24 struct component *tail;
25}; 25};
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
32static struct complist comp_list[2]; 27static struct complist comp_list[2];
33static int cur; 28static int cur;
34 29
35static struct component **comp_array; 30static struct component **comp_array;
36static size_t comp_count; 31static size_t comp_count;
37 32
@@ -537,41 +532,27 @@ component_config_commit (void)
537 } 532 }
538 else 533 else
539 comp_array = grecs_realloc (comp_array, i * sizeof (comp_array[0])); 534 comp_array = grecs_realloc (comp_array, i * sizeof (comp_array[0]));
540 comp_count = i; 535 comp_count = i;
541 536
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
573 /* Mark orphaned progs for termination */ 554 /* Mark orphaned progs for termination */
574 list = &comp_list[prev]; 555 list = &comp_list[prev];
575 if (list->head) 556 if (list->head)
576 { 557 {
577 progman_foreach (mark_prog, NULL); 558 progman_foreach (mark_prog, NULL);
@@ -582,14 +563,12 @@ component_config_commit (void)
582 component_build_depmap (); 563 component_build_depmap ();
583 564
584 /* Register new progs */ 565 /* Register new progs */
585 for (comp = comp_list[cur].head; comp; comp = comp->next) 566 for (comp = comp_list[cur].head; comp; comp = comp->next)
586 if (!comp->prog) 567 if (!comp->prog)
587 register_prog (comp); 568 register_prog (comp);
588
589 loaded = 1;
590} 569}
591 570
592static int 571static int
593component_verify (struct component *comp, grecs_locus_t *locus) 572component_verify (struct component *comp, grecs_locus_t *locus)
594{ 573{
595 int header = 0; 574 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
@@ -1450,13 +1450,15 @@ static char * const pies_type_str[] = {
1450}; 1450};
1451 1451
1452static char * const pies_comp_mode_str[] = { 1452static char * const pies_comp_mode_str[] = {
1453 [pies_comp_exec] = "exec", 1453 [pies_comp_exec] = "exec",
1454 [pies_comp_accept] = "accept", 1454 [pies_comp_accept] = "accept",
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",
1458 [pies_comp_once] = "once", 1460 [pies_comp_once] = "once",
1459 [pies_comp_boot] = "boot", 1461 [pies_comp_boot] = "boot",
1460 [pies_comp_bootwait] = "bootwait", 1462 [pies_comp_bootwait] = "bootwait",
1461 [pies_comp_powerfail] = "powerfail", 1463 [pies_comp_powerfail] = "powerfail",
1462 [pies_comp_powerwait] = "powerwait", 1464 [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
@@ -1049,13 +1049,15 @@ struct kwtrans
1049}; 1049};
1050 1050
1051struct kwtrans mode_trans[] = { 1051struct kwtrans mode_trans[] = {
1052 { "exec", 'C' }, 1052 { "exec", 'C' },
1053 { "accept", 'A' }, 1053 { "accept", 'A' },
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' },
1057 { "once", 'c' }, 1059 { "once", 'c' },
1058 { "boot", 'B' }, 1060 { "boot", 'B' },
1059 { "bootwait", 'w' }, 1061 { "bootwait", 'w' },
1060 { "powerfail", 'F' }, 1062 { "powerfail", 'F' },
1061 { "powerwait", 'f' }, 1063 { "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
26 status_stopped, /* Component is stopped. */ 26 status_stopped, /* Component is stopped. */
27 status_running, /* Component is running */ 27 status_running, /* Component is running */
28 status_listener, /* Component is an inetd listener */ 28 status_listener, /* Component is an inetd listener */
29 status_sleeping, /* Component is sleeping. An attempt to start it will 29 status_sleeping, /* Component is sleeping. An attempt to start it will
30 be made at prog->v.p.timestamp + SLEEPTIME */ 30 be made at prog->v.p.timestamp + SLEEPTIME */
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 };
34 34
35struct conn_class 35struct conn_class
36{ 36{
37 const char *tag; 37 const char *tag;
38 union pies_sockaddr_storage sa_storage; 38 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
321progman_startup_phase (void) 321progman_startup_phase (void)
322{ 322{
323 struct prog *prog; 323 struct prog *prog;
324 324
325 for (prog = proghead; prog; prog = prog->next) 325 for (prog = proghead; prog; prog = prog->next)
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;
329 } 330 }
330 return 0; 331 return 0;
331} 332}
332 333
333int 334int
@@ -335,13 +336,13 @@ progman_waiting_p (void)
335{ 336{
336 struct prog *prog; 337 struct prog *prog;
337 338
338 for (prog = proghead; prog; prog = prog->next) 339 for (prog = proghead; prog; prog = prog->next)
339 { 340 {
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))
343 { 344 {
344 debug (3, ("%s: waiting for %s (%lu)", 345 debug (3, ("%s: waiting for %s (%lu)",
345 __FUNCTION__, prog_tag (prog), 346 __FUNCTION__, prog_tag (prog),
346 (unsigned long) prog->pid)); 347 (unsigned long) prog->pid));
347 return 1; 348 return 1;
@@ -2353,20 +2354,12 @@ progman_cleanup (int expect_term)
2353 react (listener, status, pid); 2354 react (listener, status, pid);
2354 if (listener->v.p.comp->flags & CF_WAIT) 2355 if (listener->v.p.comp->flags & CF_WAIT)
2355 enable_socket (listener->v.p.socket); 2356 enable_socket (listener->v.p.socket);
2356 } 2357 }
2357 destroy_prog (&prog); 2358 destroy_prog (&prog);
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
2368 { 2361 {
2369 if (prog->v.p.comp->mode >= pies_mark_sysvinit 2362 if (prog->v.p.comp->mode >= pies_mark_sysvinit
2370 && prog->v.p.comp->mode != pies_comp_ondemand) 2363 && prog->v.p.comp->mode != pies_comp_ondemand)
2371 { 2364 {
2372 sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog), 2365 sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog),
@@ -2376,12 +2369,18 @@ progman_cleanup (int expect_term)
2376 if (prog->wait) 2369 if (prog->wait)
2377 { 2370 {
2378 pies_schedule_children (PIES_CHLD_WAKEUP); 2371 pies_schedule_children (PIES_CHLD_WAKEUP);
2379 prog->wait = 0; 2372 prog->wait = 0;
2380 } 2373 }
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
2383 { 2382 {
2384 if (is_sysvinit (prog->v.p.comp)) 2383 if (is_sysvinit (prog->v.p.comp))
2385 sysvinit_acct (SYSV_ACCT_PROC_STOP, "", 2384 sysvinit_acct (SYSV_ACCT_PROC_STOP, "",
2386 prog_tag (prog), pid, ""); 2385 prog_tag (prog), pid, "");
2387 2386

Return to:

Send suggestions and report system problems to the System administrator.