summaryrefslogtreecommitdiff
path: root/src/core/socket.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-21 17:40:04 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-21 17:40:04 -0800
commit568a84ed2d3d41da5ca64cde15a677237fffd991 (patch)
tree92ee212c0c8f4dc264acd0cef33285bddefd5a93 /src/core/socket.h
parent434cdd9f4e9211b99ba62ff6973e082b90e098f0 (diff)
downloadnng-568a84ed2d3d41da5ca64cde15a677237fffd991.tar.gz
nng-568a84ed2d3d41da5ca64cde15a677237fffd991.tar.bz2
nng-568a84ed2d3d41da5ca64cde15a677237fffd991.zip
Fix leaks in bus, socket leaks, tighten up close-side refcnting.
This does a few things. First it closes some preexisting leaks. Second it tightens the overall close logic so that we automatically discard idhash resources (while keeping numeric values for next id etc. around) when the last socket is closed. This then eliminates the need for applications to ever explicitly terminate resources. It turns out platform-specific resources established at nni_init() time might still be leaked, but it's also the case that we now no longer dynamically allocate anything at platform initialization time. (This presumes that the platform doesn't do so under the hood when creating critical sections or mutexes for example.)
Diffstat (limited to 'src/core/socket.h')
-rw-r--r--src/core/socket.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/socket.h b/src/core/socket.h
index 2a30fae5..2f34a038 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -19,6 +19,7 @@ struct nni_socket {
uint32_t s_id;
uint32_t s_refcnt;
+ nni_cv s_refcv;
nni_msgq * s_uwq; // Upper write queue
nni_msgq * s_urq; // Upper read queue
@@ -52,6 +53,7 @@ struct nni_socket {
int s_ep_pend; // EP dial/listen in progress
int s_closing; // Socket is closing
+ int s_closed; // Socket closed
int s_reapexit; // Shutdown the reaper
int s_besteffort; // Best effort mode delivery
int s_senderr; // Protocol state machine use
@@ -64,6 +66,7 @@ struct nni_socket {
};
extern int nni_sock_hold(nni_sock **, uint32_t);
+extern int nni_sock_hold_close(nni_sock **, uint32_t);
extern void nni_sock_rele(nni_sock *);
extern int nni_sock_open(nni_sock **, uint16_t);
extern void nni_sock_close(nni_sock *);