diff options
author | José Bollo <jose.bollo@iot.bzh> | 2020-05-19 11:22:26 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2020-05-19 14:11:44 +0200 |
commit | f8f2338aba84394e132fff55b6ebdef7d884292b (patch) | |
tree | dda988169851b84525431e904f473fc515868abb /src/afm-binding.c | |
parent | e7ac328451fa3b3edfbd3658a2365b75d41c0698 (diff) |
Improve use of systemd's states
A better handling of systemd state is need to treat
correctly transient states. That change includes:
- Management of states with numeric identifiers
instead of names
- Handling of the state "inactive" as a stable
state. Most of previous seen problems were coming
from that miss.
- Returning no error but also no info on the process
if it falled to "inactive" meaning that it stopped
quickly.
Bug-AGL: SPEC-3323
Change-Id: Ibf35eb6257c5583596d675cad0bec2869f5fd5f7
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afm-binding.c')
-rw-r--r-- | src/afm-binding.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/afm-binding.c b/src/afm-binding.c index 55010a2..1771520 100644 --- a/src/afm-binding.c +++ b/src/afm-binding.c @@ -402,7 +402,7 @@ static void start(afb_req_t req) /* launch the application */ runid = afm_urun_start(appli, afb_req_get_uid(req)); - if (runid <= 0) { + if (runid < 0) { cant_start(req); return; } @@ -412,7 +412,8 @@ static void start(afb_req_t req) #if 0 wrap_json_pack(&resp, "{si}", _runid_, runid); #else - wrap_json_pack(&resp, "i", runid); + if (runid) + wrap_json_pack(&resp, "i", runid); #endif afb_req_success(req, resp, NULL); } @@ -439,13 +440,13 @@ static void once(afb_req_t req) /* launch the application */ runid = afm_urun_once(appli, afb_req_get_uid(req)); - if (runid <= 0) { + if (runid < 0) { cant_start(req); return; } /* returns the state */ - resp = afm_urun_state(afudb, runid, afb_req_get_uid(req)); + resp = runid ? afm_urun_state(afudb, runid, afb_req_get_uid(req)) : NULL; afb_req_success(req, resp, NULL); } |