From: José Bollo Date: Fri, 10 Jun 2016 17:38:32 +0000 (+0200) Subject: subcall: adds an error function X-Git-Tag: blowfish_2.0.1~27 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=0a8f8f784646254d9b71e928e930003f82d89603;p=src%2Fapp-framework-binder.git subcall: adds an error function Change-Id: I9f766c4b880cc741392e5c33b58a2723b5a6f4ef Signed-off-by: José Bollo --- diff --git a/src/afb-subcall.c b/src/afb-subcall.c index bf641738..6566b5b2 100644 --- a/src/afb-subcall.c +++ b/src/afb-subcall.c @@ -159,13 +159,23 @@ static void subcall_subcall(struct afb_subcall *subcall, const char *api, const afb_subcall(&subcall->context, api, verb, args, callback, closure, (struct afb_req){ .itf = &afb_subcall_req_itf, .closure = subcall }); } +void afb_subcall_internal_error(void (*callback)(void*, int, struct json_object*), void *closure) +{ + static struct json_object *obj; + + if (obj == NULL) + obj = afb_msg_json_reply_error("failed", "internal error", NULL, NULL); + + callback(closure, 1, obj); +} + void afb_subcall(struct afb_context *context, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure, struct afb_req req) { struct afb_subcall *subcall; subcall = calloc(1, sizeof *subcall); if (subcall == NULL) { - callback(closure, 1, afb_msg_json_reply_error("failed", "out of memory", NULL, NULL)); + afb_subcall_internal_error(callback, closure); return; } diff --git a/src/afb-subcall.h b/src/afb-subcall.h index 8fbc4ad8..0de51dae 100644 --- a/src/afb-subcall.h +++ b/src/afb-subcall.h @@ -23,4 +23,5 @@ struct json_object; extern void afb_subcall(struct afb_context *context, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure, struct afb_req req); +extern void afb_subcall_internal_error(void (*callback)(void*, int, struct json_object*), void *closure);