X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-stub-ws.c;h=3c28871cdcc6836ea45cb1e0682415e654cab3d5;hb=60cd11786766ebc148b7ec088962dd6e112f8762;hp=70c74b65bbd65f5fb9049267a26eb9ebb92fab3c;hpb=043c27c3a8fd323d59e41288b6fd24f0e9bfa9a3;p=src%2Fapp-framework-binder.git diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c index 70c74b65..3c28871c 100644 --- a/src/afb-stub-ws.c +++ b/src/afb-stub-ws.c @@ -145,7 +145,7 @@ struct afb_stub_ws uint8_t is_client; /* the api name */ - char apiname[1]; + char apiname[]; }; static struct afb_proto_ws *afb_stub_ws_create_proto(struct afb_stub_ws *stubws, struct fdev *fdev, uint8_t server); @@ -266,6 +266,7 @@ static void client_api_call_cb(void * closure, struct afb_xreq *xreq) return; } + afb_xreq_unhooked_addref(xreq); rc = afb_proto_ws_client_call( proto, xreq->request.called_verb, @@ -273,10 +274,10 @@ static void client_api_call_cb(void * closure, struct afb_xreq *xreq) afb_session_uuid(xreq->context.session), xreq, xreq_on_behalf_cred_export(xreq)); - if (rc >= 0) - afb_xreq_unhooked_addref(xreq); - else + if (rc < 0) { afb_xreq_reply(xreq, NULL, "internal", "can't send message"); + afb_xreq_unhooked_unref(xreq); + } } static void client_on_description_cb(void *closure, struct json_object *data) @@ -648,7 +649,7 @@ static void on_hangup(void *closure) static int enqueue_processing(struct afb_proto_ws *proto, void (*callback)(int signum, void* arg), void *arg) { - return jobs_queue(proto, 0, callback, arg); + return jobs_queue(NULL /* proto */, 0, callback, arg); } /*****************************************************/ @@ -672,7 +673,7 @@ static struct afb_stub_ws *afb_stub_ws_create(struct fdev *fdev, const char *api { struct afb_stub_ws *stubws; - stubws = calloc(1, sizeof *stubws + strlen(apiname)); + stubws = calloc(1, sizeof *stubws + 1 + strlen(apiname)); if (stubws == NULL) errno = ENOMEM; else {