aboutsummaryrefslogtreecommitdiff
path: root/src/core/stream.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-09 23:45:21 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-11 11:03:12 -0800
commit713b80f440cb414cd0b856bde0ea1b31f939777f (patch)
tree1186c42418559c85719023bde3e919aa2df7fcef /src/core/stream.c
parentcbe9a27ef7485977fbc7c713376b096b6723da3d (diff)
downloadnng-713b80f440cb414cd0b856bde0ea1b31f939777f.tar.gz
nng-713b80f440cb414cd0b856bde0ea1b31f939777f.tar.bz2
nng-713b80f440cb414cd0b856bde0ea1b31f939777f.zip
refactor initialization/finalization
Applications must now call nng_init(), but they can supply a set of parameters optionally. The code is now safe for multiple libraries to do this concurrently, meaning nng_fini no longer can race against another instance starting up. The nni_init checks on all public APIs are removed now.
Diffstat (limited to 'src/core/stream.c')
-rw-r--r--src/core/stream.c19
1 files changed, 0 insertions, 19 deletions
diff --git a/src/core/stream.c b/src/core/stream.c
index 78029ddc..d900329a 100644
--- a/src/core/stream.c
+++ b/src/core/stream.c
@@ -169,12 +169,6 @@ nng_stream_dialer_dial(nng_stream_dialer *d, nng_aio *aio)
int
nng_stream_dialer_alloc_url(nng_stream_dialer **dp, const nng_url *url)
{
- int rv;
-
- if ((rv = nni_init()) != 0) {
- return (rv);
- }
-
for (int i = 0; stream_drivers[i].scheme != NULL; i++) {
if (strcmp(stream_drivers[i].scheme, url->u_scheme) == 0) {
return (stream_drivers[i].dialer_alloc(dp, url));
@@ -189,9 +183,6 @@ nng_stream_dialer_alloc(nng_stream_dialer **dp, const char *uri)
nng_url *url;
int rv;
- if ((rv = nni_init()) != 0) {
- return (rv);
- }
if ((rv = nng_url_parse(&url, uri)) != 0) {
return (rv);
}
@@ -291,12 +282,6 @@ nni_stream_listener_set_tls(nng_stream_listener *l, nng_tls_config *cfg)
int
nng_stream_listener_alloc_url(nng_stream_listener **lp, const nng_url *url)
{
- int rv;
-
- if ((rv = nni_init()) != 0) {
- return (rv);
- }
-
for (int i = 0; stream_drivers[i].scheme != NULL; i++) {
if (strcmp(stream_drivers[i].scheme, url->u_scheme) == 0) {
return (stream_drivers[i].listener_alloc(lp, url));
@@ -311,10 +296,6 @@ nng_stream_listener_alloc(nng_stream_listener **lp, const char *uri)
nng_url *url;
int rv;
- if ((rv = nni_init()) != 0) {
- return (rv);
- }
-
if ((rv = nng_url_parse(&url, uri)) != 0) {
return (rv);
}