X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-stub-ws.c;h=6a52f6fc5e69f9098057c1aabbb67c9dcd043bd9;hb=6dfeafe7e4fa582b3db3f950136bc97f8611fc6d;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..6a52f6fc 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) @@ -340,12 +341,12 @@ static void server_event_push_cb(void *closure, const char *event, int eventid, json_object_put(object); } -static void server_event_broadcast_cb(void *closure, const char *event, int eventid, struct json_object *object) +static void server_event_broadcast_cb(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop) { struct afb_stub_ws *stubws = closure; if (stubws->proto != NULL) - afb_proto_ws_server_event_broadcast(stubws->proto, event, object); + afb_proto_ws_server_event_broadcast(stubws->proto, event, object, uuid, hop); json_object_put(object); } @@ -456,9 +457,9 @@ static void client_on_event_push_cb(void *closure, const char *event_name, int e ERROR("unreadable push event"); } -static void client_on_event_broadcast_cb(void *closure, const char *event_name, struct json_object *data) +static void client_on_event_broadcast_cb(void *closure, const char *event_name, struct json_object *data, const uuid_binary_t uuid, uint8_t hop) { - afb_evt_broadcast(event_name, data); + afb_evt_rebroadcast(event_name, data, uuid, hop); } /*****************************************************/ @@ -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 {