aboutsummaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-12 14:25:26 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-02-12 14:25:26 +0200
commit05f16374d677f7c606d5100df3ca3499b9891aca (patch)
treeefa6177f87df2ba1e9f63edec6cc55cb621c9745 /src/comp.c
parentd9d267052215f223897af18310e4adee310308e7 (diff)
downloadpies-05f16374d677f7c606d5100df3ca3499b9891aca.tar.gz
pies-05f16374d677f7c606d5100df3ca3499b9891aca.tar.bz2
Improve progman API (progman_foreach and progman_stop_component).
* src/progman.c (progman_foreach): Allow filter to remove its prog argument from the list. Return integer (result of the call to filter, that returned non-zero). All uses changed. (progman_running_count): Remove. (progman_stop_component): Take a pointer to pointer. Pass it to destroy_prog when needed. All uses changed. * src/comp.c (prog_is_leftover): New function. (cb_terminate_prog): Use prog_is_leftover. Don't raise CF_DISABLED flag, as prog will have been destroyed by progman_stop_component. (cb_kill_prog): Use prog_is_leftover. * src/ctl.c (fun_stop): Check if prog still exists after the call to progman_stop_component. * src/pies.h (progman_running_count): Removed. * src/prog.h (progman_foreach): Return int. (progman_stop_component): Change signature.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/comp.c b/src/comp.c
index 5613e28..6a0e4ba 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -350,22 +350,28 @@ component_config_rollback (void)
350 component_free (list->head); 350 component_free (list->head);
351 cur = prev_index (); 351 cur = prev_index ();
352} 352}
353
354/* Return true if PROG is a leftover from previous configuration */
355static int
356prog_is_leftover (struct prog *prog)
357{
358 return IS_COMPONENT (prog) && !component_is_active (prog->v.p.comp);
359}
353 360
361/* If PROG is a leftover, gracefully stop it and mark as disabled */
354static int 362static int
355cb_terminate_prog (struct prog *prog, void *data) 363cb_terminate_prog (struct prog *prog, void *data)
356{ 364{
357 if (IS_COMPONENT (prog) && !component_is_active (prog->v.p.comp)) 365 if (prog_is_leftover (prog))
358 { 366 progman_stop_component (&prog);
359 progman_stop_component (prog);
360 prog->v.p.comp->flags |= CF_DISABLED;
361 }
362 return 0; 367 return 0;
363} 368}
364 369
370/* If PROG is a leftover, slay it with SIGKILL */
365static int 371static int
366cb_kill_prog (struct prog *prog, void *data) 372cb_kill_prog (struct prog *prog, void *data)
367{ 373{
368 if (!(IS_COMPONENT (prog) && component_is_active (prog->v.p.comp))) 374 if (prog_is_leftover (prog))
369 prog_stop (prog, SIGKILL); 375 prog_stop (prog, SIGKILL);
370 return 0; 376 return 0;
371} 377}
@@ -509,7 +515,7 @@ component_config_commit (void)
509 progman_wait_until (list_is_empty, list); 515 progman_wait_until (list_is_empty, list);
510 } 516 }
511 } 517 }
512 518
513 /* Build dependency map */ 519 /* Build dependency map */
514 component_build_depmap (); 520 component_build_depmap ();
515 521

Return to:

Send suggestions and report system problems to the System administrator.