diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-11-08 13:31:50 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-11-08 13:58:37 +0100 |
commit | 011a41f695cbc7aa5deca2dcee77ccf9d21f5823 (patch) | |
tree | 69567629733384081bc02ab3eca1cd3a33f14ded /src | |
parent | d7890b93b8a0a9d0cd96b07f4b4e1326a52bc012 (diff) |
renaming of verbs
The verbs 'stop' and 'continue' are now renamed
as respectively 'pause' and 'resume'.
Change-Id: I2f82105103884fc07f3c67e08c696e435aed28e1
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/afm-main-binding.c | 16 | ||||
-rw-r--r-- | src/afm-run.c | 26 | ||||
-rw-r--r-- | src/afm-run.h | 4 | ||||
-rw-r--r-- | src/afm-user-daemon.c | 43 |
4 files changed, 57 insertions, 32 deletions
diff --git a/src/afm-main-binding.c b/src/afm-main-binding.c index 6d90624..701354c 100644 --- a/src/afm-main-binding.c +++ b/src/afm-main-binding.c @@ -34,7 +34,9 @@ static const char _id_[] = "id"; static const char _install_[] = "install"; static const char _local_[] = "local"; static const char _mode_[] = "mode"; +static const char _pause_[] = "pause"; static const char _remote_[] = "remote"; +static const char _resume_[] = "resume"; static const char _runid_[] = "runid"; static const char _runnables_[] = "runnables"; static const char _runners_[] = "runners"; @@ -298,14 +300,14 @@ static void terminate(struct afb_req request) call_runid(request, _terminate_); } -static void stop(struct afb_req request) +static void pause(struct afb_req request) { - call_runid(request, _stop_); + call_runid(request, _pause_); } -static void continue_(struct afb_req request) +static void resume(struct afb_req request) { - call_runid(request, _continue_); + call_runid(request, _resume_); } static void runners(struct afb_req request) @@ -375,8 +377,10 @@ static const struct afb_verb_desc_v1 verbs[] = {_detail_ , AFB_SESSION_CHECK, detail, "Get the details for one application"}, {_start_ , AFB_SESSION_CHECK, start, "Start an application"}, {_terminate_, AFB_SESSION_CHECK, terminate, "Terminate a running application"}, - {_stop_ , AFB_SESSION_CHECK, stop, "Stop (pause) a running application"}, - {_continue_ , AFB_SESSION_CHECK, continue_, "Continue (resume) a stopped application"}, + {_pause_ , AFB_SESSION_CHECK, pause, "Pause a running application"}, + {_resume_ , AFB_SESSION_CHECK, resume, "Resume a paused application"}, + {_stop_ , AFB_SESSION_CHECK, pause, "Obsolete since 2016/11/08, use 'pause' instead"}, + {_continue_ , AFB_SESSION_CHECK, resume, "Obsolete since 2016/11/08, use 'resume' instead"}, {_runners_ , AFB_SESSION_CHECK, runners, "Get the list of running applications"}, {_state_ , AFB_SESSION_CHECK, state, "Get the state of a running application"}, {_install_ , AFB_SESSION_CHECK, install, "Install an application using a widget file"}, diff --git a/src/afm-run.c b/src/afm-run.c index 4de0fd2..131f9cb 100644 --- a/src/afm-run.c +++ b/src/afm-run.c @@ -51,7 +51,7 @@ enum appstate { as_starting, /* start in progress */ as_running, /* started and running */ - as_stopped, /* stopped */ + as_paused, /* paused */ as_terminating, /* termination in progress */ as_terminated /* terminated */ }; @@ -279,11 +279,11 @@ static void started(int runid) { } -static void stopped(int runid) +static void paused(int runid) { } -static void continued(int runid) +static void resumed(int runid) { } @@ -302,7 +302,7 @@ static void removed(int runid) * for 'runid' and put the runner's state to 'tostate' * in case of success. * - * Only processes in the state 'as_running' or 'as_stopped' + * Only processes in the state 'as_running' or 'as_paused' * can be signalled. * * Returns 0 in case of success or -1 in case of error. @@ -315,7 +315,7 @@ static int killrunner(int runid, int sig, enum appstate tostate) errno = ENOENT; rc = -1; } - else if (runner->state != as_running && runner->state != as_stopped) { + else if (runner->state != as_running && runner->state != as_paused) { errno = EINVAL; rc = -1; } @@ -354,13 +354,13 @@ static void on_sigchld(int signum, siginfo_t *info, void *uctxt) pgid_remove(runner); runner->next_by_pgid = terminated_runners; terminated_runners = runner; - /* ensures that all the group stops */ + /* ensures that all the group terminates */ killpg(runner->pids[0], SIGKILL); break; case CLD_STOPPED: /* update the state */ - runner->state = as_stopped; + runner->state = as_paused; break; case CLD_CONTINUED: @@ -437,7 +437,7 @@ static json_object *mkstate(struct apprun *runner) switch(runner->state) { case as_starting: case as_running: - case as_stopped: + case as_paused: pids = j_add_new_array(result, "pids"); if (!pids) goto error2; @@ -456,8 +456,8 @@ static json_object *mkstate(struct apprun *runner) case as_running: state = "running"; break; - case as_stopped: - state = "stopped"; + case as_paused: + state = "paused"; break; default: state = "terminated"; @@ -558,9 +558,9 @@ int afm_run_terminate(int runid) * * Returns 0 in case of success or -1 in case of error */ -int afm_run_stop(int runid) +int afm_run_pause(int runid) { - return killrunner(runid, SIGSTOP, as_stopped); + return killrunner(runid, SIGSTOP, as_paused); } /* @@ -568,7 +568,7 @@ int afm_run_stop(int runid) * * Returns 0 in case of success or -1 in case of error */ -int afm_run_continue(int runid) +int afm_run_resume(int runid) { return killrunner(runid, SIGCONT, as_running); } diff --git a/src/afm-run.h b/src/afm-run.h index 5b2e2b8..6e3469a 100644 --- a/src/afm-run.h +++ b/src/afm-run.h @@ -18,8 +18,8 @@ extern int afm_run_start(struct json_object *appli, enum afm_launch_mode mode, char **uri); extern int afm_run_terminate(int runid); -extern int afm_run_stop(int runid); -extern int afm_run_continue(int runid); +extern int afm_run_pause(int runid); +extern int afm_run_resume(int runid); extern struct json_object *afm_run_list(); extern struct json_object *afm_run_state(int runid); diff --git a/src/afm-user-daemon.c b/src/afm-user-daemon.c index aecea8d..e71e011 100644 --- a/src/afm-user-daemon.c +++ b/src/afm-user-daemon.c @@ -246,7 +246,7 @@ static void on_start(struct sd_bus_message *smsg, struct json_object *obj, void && j_add_string(resp, "uri", uri)) jbus_reply_j(smsg, resp); else { - afm_run_stop(runid); + afm_run_terminate(runid); jbus_reply_error_s(smsg, error_system); } json_object_put(resp); @@ -254,30 +254,48 @@ static void on_start(struct sd_bus_message *smsg, struct json_object *obj, void } /* - * On query "stop" from 'smsg' with parameters of 'obj'. + * On query "pause" from 'smsg' with parameters of 'obj'. */ -static void on_stop(struct sd_bus_message *smsg, struct json_object *obj, void *unused) +static void on_pause(struct sd_bus_message *smsg, struct json_object *obj, void *unused) { int runid, status; - if (onrunid(smsg, obj, "stop", &runid)) { - status = afm_run_stop(runid); + if (onrunid(smsg, obj, "pause", &runid)) { + status = afm_run_pause(runid); reply_status(smsg, status, error_not_found); } } /* - * On query "continue" from 'smsg' with parameters of 'obj'. + * On query "resume" from 'smsg' with parameters of 'obj'. */ -static void on_continue(struct sd_bus_message *smsg, struct json_object *obj, void *unused) +static void on_resume(struct sd_bus_message *smsg, struct json_object *obj, void *unused) { int runid, status; - if (onrunid(smsg, obj, "continue", &runid)) { - status = afm_run_continue(runid); + if (onrunid(smsg, obj, "resume", &runid)) { + status = afm_run_resume(runid); reply_status(smsg, status, error_not_found); } } /* + * On query "stop" from 'smsg' with parameters of 'obj'. + */ +static void on_stop(struct sd_bus_message *smsg, struct json_object *obj, void *unused) +{ + NOTICE("call to obsolete 'stop'"); + on_pause(smsg, obj, unused); +} + +/* + * On query "continue" from 'smsg' with parameters of 'obj'. + */ +static void on_continue(struct sd_bus_message *smsg, struct json_object *obj, void *unused) +{ + NOTICE("call to obsolete 'continue'"); + on_resume(smsg, obj, unused); +} + +/* * On query "terminate" from 'smsg' with parameters of 'obj'. */ static void on_terminate(struct sd_bus_message *smsg, struct json_object *obj, void *unused) @@ -583,17 +601,20 @@ int main(int ac, char **av) || jbus_add_service_j(user_bus, "detail", on_detail, NULL) || jbus_add_service_j(user_bus, "start", on_start, NULL) || jbus_add_service_j(user_bus, "terminate", on_terminate, NULL) + || jbus_add_service_j(user_bus, "pause", on_pause, NULL) + || jbus_add_service_j(user_bus, "resume", on_resume, NULL) || jbus_add_service_j(user_bus, "stop", on_stop, NULL) || jbus_add_service_j(user_bus, "continue", on_continue, NULL) || jbus_add_service_j(user_bus, "runners", on_runners, NULL) || jbus_add_service_j(user_bus, "state", on_state, NULL) #if defined(EXPLICIT_CALL) || jbus_add_service_s(user_bus, "install", on_install, NULL) - || jbus_add_service_s(user_bus, "uninstall", on_uninstall, NULL)) { + || jbus_add_service_s(user_bus, "uninstall", on_uninstall, NULL) #else || jbus_add_service_s(user_bus, "install", (void (*)(struct sd_bus_message *, const char *, void *))propagate, "install") - || jbus_add_service_s(user_bus, "uninstall", (void (*)(struct sd_bus_message *, const char *, void *))propagate, "uninstall")) { + || jbus_add_service_s(user_bus, "uninstall", (void (*)(struct sd_bus_message *, const char *, void *))propagate, "uninstall") #endif + ) { ERROR("adding services failed"); return 1; } |