aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/websocket/websocket_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-12 17:55:48 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-12 17:55:48 -0800
commit81f5d3c6268ff91ee9c36c4cb34f6f9bfd54740d (patch)
treef9f21aa66bd22cfd95ae0c4b8abe57036c8fce0d /src/supplemental/websocket/websocket_test.c
parent371eedeeb6fafe628ae89b9ad2690fa3d6a57e8a (diff)
downloadnng-81f5d3c6268ff91ee9c36c4cb34f6f9bfd54740d.tar.gz
nng-81f5d3c6268ff91ee9c36c4cb34f6f9bfd54740d.tar.bz2
nng-81f5d3c6268ff91ee9c36c4cb34f6f9bfd54740d.zip
streams: add explicit stop functions
This allows us to explicitly stop streams, dialers, and listeners, before we start tearing down things. This hopefully will be useful in resolving use-after-free bugs in http, tls, and websockets. The new functions are not yet documented, but they are nng_stream_stop, nng_stream_dialer_stop, and nng_stream_listener_stop. They should be called after close, and before free. The close functions now close without blocking, but the stop function is allowed to block.
Diffstat (limited to 'src/supplemental/websocket/websocket_test.c')
-rw-r--r--src/supplemental/websocket/websocket_test.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/supplemental/websocket/websocket_test.c b/src/supplemental/websocket/websocket_test.c
index 781ca1d8..9a28d69b 100644
--- a/src/supplemental/websocket/websocket_test.c
+++ b/src/supplemental/websocket/websocket_test.c
@@ -107,9 +107,13 @@ test_websocket_wildcard(void)
NUTS_TRUE(memcmp(buf1, buf2, 5) == 0);
nng_stream_close(c1);
- nng_stream_free(c1);
nng_stream_close(c2);
+ nng_stream_stop(c1);
+ nng_stream_stop(c2);
+ nng_stream_free(c1);
nng_stream_free(c2);
+ nng_stream_listener_stop(l);
+ nng_stream_dialer_stop(d);
nng_aio_free(daio);
nng_aio_free(laio);
nng_aio_free(aio1);
@@ -206,9 +210,13 @@ test_websocket_conn_props(void)
nng_strfree(str);
nng_stream_close(c1);
- nng_stream_free(c1);
nng_stream_close(c2);
+ nng_stream_stop(c1);
+ nng_stream_stop(c2);
+ nng_stream_free(c1);
nng_stream_free(c2);
+ nng_stream_listener_stop(l);
+ nng_stream_dialer_stop(d);
nng_aio_free(daio);
nng_aio_free(laio);
nng_stream_listener_free(l);
@@ -495,6 +503,7 @@ test_websocket_fragmentation(void)
nng_aio_free(caio);
nng_stream_close(c);
+ nng_stream_stop(c);
nng_stream_free(c);
nng_aio_free(state.aio);
@@ -502,6 +511,8 @@ test_websocket_fragmentation(void)
nng_cv_free(state.cv);
nng_mtx_free(state.lock);
+ nng_stream_dialer_stop(d);
+ nng_stream_listener_stop(l);
nng_free(send_buf, state.total);
nng_free(recv_buf, state.total);
nng_aio_free(daio);