From 05f16374d677f7c606d5100df3ca3499b9891aca Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 12 Feb 2016 12:25:26 +0000 Subject: 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. --- (limited to 'src/ctl.c') diff --git a/src/ctl.c b/src/ctl.c index 489fc7f..bc2f78d 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -1866,8 +1866,9 @@ fun_stop (struct json_value *result, struct prog *prog) } else { - progman_stop_component (prog); - prog->v.p.comp->flags |= CF_DISABLED; + progman_stop_component (&prog); + if (prog) + prog->v.p.comp->flags |= CF_DISABLED; json_object_set_string (result, "status", "OK"); } return 0; @@ -1903,7 +1904,7 @@ fun_start (struct json_value *result, struct prog *prog) static int fun_restart (struct json_value *result, struct prog *prog) { - progman_stop_component (prog); + progman_stop_component (&prog); json_object_set_string (result, "status", "OK"); return 0; } -- cgit v0.9.0.3