Bug-AGL: SPEC-1872
Change-Id: I6e48baa05312b1490edd38ccf9231afe4aa6eb51
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
#include <string.h>
#include <assert.h>
#include <signal.h>
#include <string.h>
#include <assert.h>
#include <signal.h>
* Sends the reply 'resp' to the request 'req' if 'resp' is not NULLzero.
* Otherwise, when 'resp' is NULL replies the error string 'errstr'.
*/
* 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);
- 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'.
*/
}
/*
* 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));
int runid, status;
if (onrunid(req, "pause", &runid)) {
status = afm_urun_pause(runid, afb_req_get_uid(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);
int runid, status;
if (onrunid(req, "resume", &runid)) {
status = afm_urun_resume(runid, afb_req_get_uid(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);
int runid, status;
if (onrunid(req, "terminate", &runid)) {
status = afm_urun_terminate(runid, afb_req_get_uid(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);
struct json_object *resp;
if (onrunid(req, "state", &runid)) {
resp = afm_urun_state(afudb, runid, afb_req_get_uid(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_);
struct wgt_info *ifo;
const struct wgt_desc *desc;
char installdir[PATH_MAX];
struct wgt_info *ifo;
const struct wgt_desc *desc;
char installdir[PATH_MAX];
struct unitconf uconf;
NOTICE("-- INSTALLING widget %s to %s --", wgtfile, root);
struct unitconf uconf;
NOTICE("-- INSTALLING widget %s to %s --", wgtfile, root);
wgt_info_unref(ifo);
error2:
wgt_info_unref(ifo);
error2: