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/stream.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core/stream.h') diff --git a/src/core/stream.h b/src/core/stream.h index 9ea65834..e09dc9e5 100644 --- a/src/core/stream.h +++ b/src/core/stream.h @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -43,6 +43,7 @@ extern int nni_stream_listener_get_tls( struct nng_stream { void (*s_free)(void *); void (*s_close)(void *); + void (*s_stop)(void *); void (*s_recv)(void *, nng_aio *); void (*s_send)(void *, nng_aio *); int (*s_get)(void *, const char *, void *, size_t *, nni_type); @@ -53,6 +54,7 @@ struct nng_stream { struct nng_stream_dialer { void (*sd_free)(void *); void (*sd_close)(void *); + void (*sd_stop)(void *); void (*sd_dial)(void *, nng_aio *); int (*sd_get)(void *, const char *, void *, size_t *, nni_type); int (*sd_set)(void *, const char *, const void *, size_t, nni_type); @@ -65,6 +67,7 @@ struct nng_stream_dialer { struct nng_stream_listener { void (*sl_free)(void *); void (*sl_close)(void *); + void (*sl_stop)(void *); int (*sl_listen)(void *); void (*sl_accept)(void *, nng_aio *); int (*sl_get)(void *, const char *, void *, size_t *, nni_type); -- cgit v1.2.3-70-g09d2