aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2023-12-17 20:18:39 -0800
committerGarrett D'Amore <garrett@damore.org>2023-12-17 20:18:39 -0800
commit9528f41e847e85205d4f3a74fd1340836a219f6d (patch)
tree5b1a077485097a2f188996c10a89c8863baa354c
parent8ff9663c06a18d6c7fe0605de679948d3c4de9d7 (diff)
downloadnng-9528f41e847e85205d4f3a74fd1340836a219f6d.tar.gz
nng-9528f41e847e85205d4f3a74fd1340836a219f6d.tar.bz2
nng-9528f41e847e85205d4f3a74fd1340836a219f6d.zip
fixes #1734 websocket dialer hang on shutdown
It's not absolutely clear that this fixes all of the possible cases, but we're hopeful that this does -- and in any event the bug does not seem to reproduce easily anymore.
-rw-r--r--src/supplemental/websocket/websocket.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c
index 2ef152f9..53a262c5 100644
--- a/src/supplemental/websocket/websocket.c
+++ b/src/supplemental/websocket/websocket.c
@@ -1325,9 +1325,15 @@ ws_http_cb_dialer(nni_ws *ws, nni_aio *aio)
goto err;
}
+ // There is a race between the dialer closing and any connections
+ // that were in progress completing.
+ if (d->closed){
+ rv = NNG_ECLOSED;
+ goto err;
+ }
+
// If we have no response structure, then this was completion
- // of the send of the request. Prepare an empty response, and
- // read it.
+ // of sending the request. Prepare an empty response, and read it.
if (ws->res == NULL) {
if ((rv = nni_http_res_alloc(&ws->res)) != 0) {
goto err;