From f8f2338aba84394e132fff55b6ebdef7d884292b Mon Sep 17 00:00:00 2001 From: José Bollo Date: Tue, 19 May 2020 11:22:26 +0200 Subject: Improve use of systemd's states MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/afm-binding.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/afm-binding.c') 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); } -- cgit 1.2.3-korg