diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-12-12 17:55:48 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-12-12 17:55:48 -0800 |
| commit | 81f5d3c6268ff91ee9c36c4cb34f6f9bfd54740d (patch) | |
| tree | f9f21aa66bd22cfd95ae0c4b8abe57036c8fce0d /demo/stream | |
| parent | 371eedeeb6fafe628ae89b9ad2690fa3d6a57e8a (diff) | |
| download | nng-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 'demo/stream')
| -rw-r--r-- | demo/stream/stream.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/demo/stream/stream.c b/demo/stream/stream.c index c6cc9b23..5a4995e6 100644 --- a/demo/stream/stream.c +++ b/demo/stream/stream.c @@ -55,7 +55,7 @@ int client(const char *url) { nng_stream_dialer *dialer; - nng_aio * aio; + nng_aio *aio; nng_iov iov; int rv; @@ -102,6 +102,11 @@ client(const char *url) // Send ELCOSE to send/recv associated wit this stream free(iov.iov_buf); + + // stop everything before freeing + nng_stream_stop(c1); + nng_stream_dialer_stop(dialer); + nng_stream_free(c1); nng_aio_free(aio); nng_stream_dialer_free(dialer); |
