diff options
author | Jose Bollo <jose.bollo@iot.bzh> | 2018-08-20 17:45:42 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-08-23 08:35:38 +0200 |
commit | e36f8d572ca660f5c06fe45297d13c7a6818cc65 (patch) | |
tree | 51cf8b93d3d7a636d2f6fbab8057f10ee0f3ef0d /src/afb-proto-ws.c | |
parent | a1a507793efff92b35603e4948e9f6dff4fba99c (diff) |
Send error replies on disconnection
The pending calls receive an error notification
when the server hang up.
Bug-AGL: SPEC-1668
Change-Id: I052dca5e338a7650d7630856e21f1d3a81c6f265
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-proto-ws.c')
-rw-r--r-- | src/afb-proto-ws.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/afb-proto-ws.c b/src/afb-proto-ws.c index c079bf69..89d4522c 100644 --- a/src/afb-proto-ws.c +++ b/src/afb-proto-ws.c @@ -89,7 +89,7 @@ For the purpose of handling events the server can: struct client_call { struct client_call *next; /* the next call */ struct afb_proto_ws *protows; /* the proto_ws */ - void *request; + void *request; /* the request closure */ uint32_t callid; /* the message identifier */ }; @@ -936,8 +936,18 @@ static void on_hangup(void *closure) { struct afb_proto_ws *protows = closure; struct client_describe *cd, *ncd; + struct client_call *call, *ncall; + + ncd = __atomic_exchange_n(&protows->describes, NULL, __ATOMIC_RELAXED); + ncall = __atomic_exchange_n(&protows->calls, NULL, __ATOMIC_RELAXED); + + while (ncall) { + call= ncall; + ncall = call->next; + protows->client_itf->on_reply(protows->closure, call->request, NULL, "disconnected", "server hung up"); + free(call); + } - ncd = protows->describes; while (ncd) { cd= ncd; ncd = cd->next; |