diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-12 14:25:26 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-12 14:25:26 +0200 |
commit | 05f16374d677f7c606d5100df3ca3499b9891aca (patch) | |
tree | efa6177f87df2ba1e9f63edec6cc55cb621c9745 /src/ctl.c | |
parent | d9d267052215f223897af18310e4adee310308e7 (diff) | |
download | pies-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/ctl.c')
-rw-r--r-- | src/ctl.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1866,7 +1866,8 @@ fun_stop (struct json_value *result, struct prog *prog) | |||
1866 | } | 1866 | } |
1867 | else | 1867 | else |
1868 | { | 1868 | { |
1869 | progman_stop_component (prog); | 1869 | progman_stop_component (&prog); |
1870 | if (prog) | ||
1870 | prog->v.p.comp->flags |= CF_DISABLED; | 1871 | prog->v.p.comp->flags |= CF_DISABLED; |
1871 | json_object_set_string (result, "status", "OK"); | 1872 | json_object_set_string (result, "status", "OK"); |
1872 | } | 1873 | } |
@@ -1903,7 +1904,7 @@ fun_start (struct json_value *result, struct prog *prog) | |||
1903 | static int | 1904 | static int |
1904 | fun_restart (struct json_value *result, struct prog *prog) | 1905 | fun_restart (struct json_value *result, struct prog *prog) |
1905 | { | 1906 | { |
1906 | progman_stop_component (prog); | 1907 | progman_stop_component (&prog); |
1907 | json_object_set_string (result, "status", "OK"); | 1908 | json_object_set_string (result, "status", "OK"); |
1908 | return 0; | 1909 | return 0; |
1909 | } | 1910 | } |