X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafm-binding.c;h=5fb1f73d32e66bb3468089b34459bfc410862af4;hb=bceaf2cc403176fd808d4e00be893671be3f4bb0;hp=dd59be9343dd6c7c6f33569c20892d777d3691f6;hpb=4709f00f2236f40c606cbd318eb4fecc8d4af924;p=src%2Fapp-framework-main.git diff --git a/src/afm-binding.c b/src/afm-binding.c index dd59be9..5fb1f73 100644 --- a/src/afm-binding.c +++ b/src/afm-binding.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -295,21 +296,21 @@ static int onrunid(afb_req_t req, const char *method, int *runid) * Sends the reply 'resp' to the request 'req' if 'resp' is not NULLzero. * Otherwise, when 'resp' is NULL replies the error string 'errstr'. */ -static void reply(afb_req_t req, struct json_object *resp, const char *errstr) +static void reply(afb_req_t req, struct json_object *resp) { - if (!resp) - afb_req_fail(req, errstr, NULL); + if (resp) + afb_req_reply(req, resp, NULL, NULL); else - afb_req_success(req, resp, NULL); + afb_req_reply(req, NULL, "failed", strerror(errno)); } /* * Sends the reply "true" to the request 'req' if 'status' is zero. * Otherwise, when 'status' is not zero replies the error string 'errstr'. */ -static void reply_status(afb_req_t req, int status, const char *errstr) +static void reply_status(afb_req_t req, int status) { - reply(req, status ? NULL : json_object_get(json_true), errstr); + reply(req, status ? NULL : json_object_get(json_true)); } /* @@ -429,7 +430,7 @@ static void pause(afb_req_t req) int runid, status; if (onrunid(req, "pause", &runid)) { status = afm_urun_pause(runid, afb_req_get_uid(req)); - reply_status(req, status, _not_found_); + reply_status(req, status); } } @@ -441,7 +442,7 @@ static void resume(afb_req_t req) int runid, status; if (onrunid(req, "resume", &runid)) { status = afm_urun_resume(runid, afb_req_get_uid(req)); - reply_status(req, status, _not_found_); + reply_status(req, status); } } @@ -453,7 +454,7 @@ static void terminate(afb_req_t req) int runid, status; if (onrunid(req, "terminate", &runid)) { status = afm_urun_terminate(runid, afb_req_get_uid(req)); - reply_status(req, status, _not_found_); + reply_status(req, status); } } @@ -476,7 +477,7 @@ static void state(afb_req_t req) struct json_object *resp; if (onrunid(req, "state", &runid)) { resp = afm_urun_state(afudb, runid, afb_req_get_uid(req)); - reply(req, resp, _not_found_); + reply(req, resp); } }