aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-xreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-05-29 14:16:13 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-05-29 14:16:13 +0200
commit090379fdaf6ed1860dcff21424135ad71ead0cd2 (patch)
treeb7c9bde501e86a9fcf4a801444a670de3339208a /src/afb-xreq.c
parentce8d87d91aa710702b02a371278f4e1f39ea195c (diff)
Add 'afb_service_call_sync' function
This new function allows to call features for the services synchronously. Also refactoring how are handled arguments to calls. The call to 'json_object_put' is now always done by the binder. Change-Id: I910517da75b179aeafc824da4ce29bc299711990 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-xreq.c')
-rw-r--r--src/afb-xreq.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index 4c5becca..9478f154 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -179,10 +179,12 @@ static void xreq_subcall_cb(void *closure, const char *api, const char *verb, st
{
struct afb_xreq *xreq = closure;
- if (xreq->queryitf->subcall)
+ if (xreq->queryitf->subcall) {
xreq->queryitf->subcall(xreq, api, verb, args, callback, cb_closure);
- else
+ json_object_put(args);
+ } else {
afb_subcall(xreq, api, verb, args, callback, cb_closure);
+ }
}
struct xreq_sync
@@ -220,7 +222,7 @@ static void xreq_sync_enter(int signum, void *closure, struct jobloop *jobloop)
if (!signum) {
sync->jobloop = jobloop;
- xreq_subcall_cb(sync->caller, sync->api, sync->verb, sync->args, xreq_sync_reply, sync);
+ xreq_subcall_cb(sync->caller, sync->api, sync->verb, json_object_get(sync->args), xreq_sync_reply, sync);
} else {
sync->iserror = 1;
xreq_sync_leave(sync);
@@ -242,6 +244,7 @@ static int xreq_subcallsync_cb(void *closure, const char *api, const char *verb,
sync.iserror = 1;
rc = jobs_enter(NULL, 0, xreq_sync_enter, &sync);
+ json_object_put(args);
if (rc < 0 || sync.iserror) {
*result = sync.result ? : afb_msg_json_internal_error();
return 0;