X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-stub-ws.c;h=0e777f5ae0c9899d8952b479c469a669c8e88080;hb=bc8929bec96e81a7f487d5689f52335b435f0e3e;hp=a41a9b024f3a8f74ea460de01ac6063edee8bca1;hpb=2991a2564bc5e21b04dcb3157ce38804080c0056;p=src%2Fapp-framework-binder.git diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c index a41a9b02..0e777f5a 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); @@ -235,6 +235,7 @@ static struct client_event *client_event_search(struct afb_stub_ws *stubws, uint while (ev != NULL && (ev->id != eventid || 0 != strcmp(afb_evt_event_x2_fullname(ev->event), name))) ev = ev->next; + DEBUG("searching event %s[%d]: %s", name, eventid, ev ? "found" : "not found"); return ev; } @@ -265,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, @@ -272,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) @@ -645,9 +647,9 @@ static void on_hangup(void *closure) } } -static int enqueue_processing(void (*callback)(int signum, void* arg), void *arg) +static int enqueue_processing(struct afb_proto_ws *proto, void (*callback)(int signum, void* arg), void *arg) { - return jobs_queue(NULL, 0, callback, arg); + return jobs_queue(NULL /* proto */, 0, callback, arg); } /*****************************************************/ @@ -671,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 {