aboutsummaryrefslogtreecommitdiff
path: root/src/core/stream.h
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/core/stream.h
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/core/stream.h')
-rw-r--r--src/core/stream.h5
1 files changed, 4 insertions, 1 deletions
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. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// 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);