X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fafb-stub-ws.c;h=5000f9f98714c97d9463f1368e531c5cb6b55330;hb=refs%2Fchanges%2F53%2F16253%2F2;hp=974ea07e089ccd35e569978a9890577ac49d4d4e;hpb=12ec841c28f8f795b49466cc377e64db3146430d;p=src%2Fapp-framework-binder.git diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c index 974ea07e..5000f9f9 100644 --- a/src/afb-stub-ws.c +++ b/src/afb-stub-ws.c @@ -50,16 +50,6 @@ struct afb_stub_ws; -/* - * structure for recording calls on client side - */ -struct client_call { - struct client_call *next; /* the next call */ - struct afb_stub_ws *stubws; /* the stub_ws */ - struct afb_xreq *xreq; /* the request handle */ - uint32_t msgid; /* the message identifier */ -}; - /* * structure for a ws request */ @@ -220,16 +210,20 @@ static struct client_event *client_event_search(struct afb_stub_ws *stubws, uint /* on call, propagate it to the ws service */ static void client_call_cb(void * closure, struct afb_xreq *xreq) { + int rc; struct afb_stub_ws *stubws = closure; - afb_proto_ws_client_call( + rc = afb_proto_ws_client_call( stubws->proto, xreq->request.called_verb, afb_xreq_json(xreq), afb_session_uuid(xreq->context.session), xreq, xreq_on_behalf_cred_export(xreq)); - afb_xreq_unhooked_addref(xreq); + if (rc >= 0) + afb_xreq_unhooked_addref(xreq); + else + afb_xreq_reply(xreq, NULL, "internal", "can't send message"); } static void client_on_description_cb(void *closure, struct json_object *data) @@ -440,8 +434,7 @@ static void release_all_sessions(struct afb_stub_ws *stubws) { struct server_session *s, *n; - s = stubws->sessions; - stubws->sessions = NULL; + s = __atomic_exchange_n(&stubws->sessions, NULL, __ATOMIC_RELAXED); while(s) { n = s->next; afb_session_unref(s->session); @@ -597,6 +590,11 @@ static void on_hangup(void *closure) afb_stub_ws_unref(stubws); } +static int enqueue_processing(void (*callback)(int signum, void* arg), void *arg) +{ + return jobs_queue(NULL, 0, callback, arg); +} + /*****************************************************/ static struct afb_stub_ws *afb_stub_ws_create(struct fdev *fdev, const char *apiname, struct afb_apiset *apiset, int client) @@ -617,6 +615,7 @@ static struct afb_stub_ws *afb_stub_ws_create(struct fdev *fdev, const char *api stubws->apiset = afb_apiset_addref(apiset); stubws->refcount = 1; afb_proto_ws_on_hangup(stubws->proto, on_hangup); + afb_proto_ws_set_queuing(stubws->proto, enqueue_processing); return stubws; } free(stubws); @@ -664,7 +663,7 @@ void afb_stub_ws_addref(struct afb_stub_ws *stubws) __atomic_add_fetch(&stubws->refcount, 1, __ATOMIC_RELAXED); } -void afb_stub_ws_on_hangup(struct afb_stub_ws *stubws, void (*on_hangup)(struct afb_stub_ws*)) +void afb_stub_ws_set_on_hangup(struct afb_stub_ws *stubws, void (*on_hangup)(struct afb_stub_ws*)) { stubws->on_hangup = on_hangup; }