diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-02-19 08:41:12 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-02-19 08:41:12 +0200 |
commit | e6902abfddb4d7b16dc9a4231a3781f354a08cd5 (patch) | |
tree | c634621af2ae765460e010ce83c8492ed4e859bc /src/comp.c | |
parent | 51a797445a4bfc34ad1ae7ea91e12486d823abda (diff) | |
download | pies-e6902abfddb4d7b16dc9a4231a3781f354a08cd5.tar.gz pies-e6902abfddb4d7b16dc9a4231a3781f354a08cd5.tar.bz2 |
Revamp program termination after reconfiguring.
* src/pies.h (PIES_CHLD_GC): New op.
(progman_stop_tag): Remove proto.
* src/pies.c (main): Handle PIES_CHLD_GC: stop all programs marked
for termination.
* src/comp.c (component_config_commit): Mark leftover components
for termination, instead of waiting for them to terminate.
* src/sysvinit.c (runlevel_setup_prog): Skip prog if its
active status didn't change.
Mark inactivated progs for termination.
(sysvinit_runlevel_setup): Schedule PIES_CHLD_GC.
(inittrans): Don't wait for programs to terminate. That will be done
in the main loop.
* src/prog.h (prog)<stop>: New boolean member.
* src/progman.c (progman_cleanup)
(progman_stop_component): Clear the stop flag.
(progman_gc): New function.
(progman_stop_tag): Remove.
Diffstat (limited to 'src/comp.c')
-rw-r--r-- | src/comp.c | 32 |
1 files changed, 6 insertions, 26 deletions
@@ -360,8 +360,8 @@ prog_is_leftover (struct prog *prog) | |||
360 | 360 | ||
361 | /* If PROG is a leftover, gracefully stop it and mark as disabled */ | 361 | /* If PROG is a leftover, mark it for termination */ |
362 | static int | 362 | static int |
363 | cb_terminate_prog (struct prog *prog, void *data) | 363 | mark_prog (struct prog *prog, void *data) |
364 | { | 364 | { |
365 | if (prog_is_leftover (prog)) | 365 | if (prog_is_leftover (prog)) |
366 | progman_stop_component (&prog); | 366 | prog->v.p.stop = 1; |
367 | return 0; | 367 | return 0; |
@@ -369,18 +369,2 @@ cb_terminate_prog (struct prog *prog, void *data) | |||
369 | 369 | ||
370 | /* If PROG is a leftover, slay it with SIGKILL */ | ||
371 | static int | ||
372 | cb_kill_prog (struct prog *prog, void *data) | ||
373 | { | ||
374 | if (prog_is_leftover (prog)) | ||
375 | prog_stop (prog, SIGKILL); | ||
376 | return 0; | ||
377 | } | ||
378 | |||
379 | static int | ||
380 | list_is_empty (void *p) | ||
381 | { | ||
382 | struct complist *list = p; | ||
383 | return list->head == NULL; | ||
384 | } | ||
385 | |||
386 | static int | 370 | static int |
@@ -506,3 +490,3 @@ component_config_commit (void) | |||
506 | 490 | ||
507 | /* Terminate orphaned progs */ | 491 | /* Mark orphaned progs for termination */ |
508 | list = &comp_list[prev]; | 492 | list = &comp_list[prev]; |
@@ -510,8 +494,4 @@ component_config_commit (void) | |||
510 | { | 494 | { |
511 | progman_foreach (cb_terminate_prog, NULL); | 495 | progman_foreach (mark_prog, NULL); |
512 | if (progman_wait_until (list_is_empty, list)) | 496 | pies_schedule_children (PIES_CHLD_GC); |
513 | { | ||
514 | progman_foreach (cb_kill_prog, NULL); | ||
515 | progman_wait_until (list_is_empty, list); | ||
516 | } | ||
517 | } | 497 | } |