From 9528f41e847e85205d4f3a74fd1340836a219f6d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 17 Dec 2023 20:18:39 -0800 Subject: [PATCH] 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. --- src/supplemental/websocket/websocket.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c index 2ef152f91..53a262c52 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;