From 81f5d3c6268ff91ee9c36c4cb34f6f9bfd54740d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 12 Dec 2024 17:55:48 -0800 Subject: 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. --- src/core/platform.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core/platform.h') diff --git a/src/core/platform.h b/src/core/platform.h index d2409e5b..2f5b5c17 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -293,6 +293,7 @@ extern void nni_tcp_dialer_fini(nni_tcp_dialer *); // Further operations on it should return NNG_ECLOSED. // Any in-progress connection will be aborted. extern void nni_tcp_dialer_close(nni_tcp_dialer *); +extern void nni_tcp_dialer_stop(nni_tcp_dialer *); // nni_tcp_dial attempts to create an outgoing connection, // asynchronously, to the address in the aio. On success, the first (and only) @@ -318,6 +319,10 @@ extern void nni_tcp_listener_fini(nni_tcp_listener *); // any bound socket, and further operations will result in NNG_ECLOSED. extern void nni_tcp_listener_close(nni_tcp_listener *); +// nni_tcp_listener_stop is close + waits for any operations to stop, +// so there won't be any further accepts after this. +extern void nni_tcp_listener_stop(nni_tcp_listener *); + // nni_tcp_listener_listen creates the socket in listening mode, bound // to the specified address. extern int nni_tcp_listener_listen(nni_tcp_listener *, const nni_sockaddr *); -- cgit v1.2.3-70-g09d2