summaryrefslogtreecommitdiff
path: root/src/core/init.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/init.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/init.h')
-rw-r--r--src/core/init.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/init.h b/src/core/init.h
index bae78fc3..e48b6705 100644
--- a/src/core/init.h
+++ b/src/core/init.h
@@ -15,17 +15,17 @@
// nni_init is called each time the user enters the library. It ensures that
// the library is initlialized properly, and also deals with checks such as
// whether the process has forked since last initialization.
-extern int nni_init(void);
+int nni_init(void);
// nni_fini tears everything down. In the future it may be used to ensure
// that all resources used by the library are released back to the system.
-extern void nni_fini(void);
+void nni_fini(void);
// Private hash tables matching IDs to values. Consumers need to use the
// nni_idlock to protect access to these.
-nni_idhash *nni_endpoints;
-nni_idhash *nni_pipes;
-nni_idhash *nni_sockets;
-nni_mtx *nni_idlock;
+extern nni_mtx *nni_idlock;
+extern nni_idhash *nni_endpoints;
+extern nni_idhash *nni_pipes;
+extern nni_idhash *nni_sockets;
#endif // CORE_INIT_H