From 713b80f440cb414cd0b856bde0ea1b31f939777f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 9 Nov 2024 23:45:21 -0800 Subject: 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. --- src/sp/protocol/pubsub0/sub.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/sp/protocol') diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c index a4741114..1b17fcbf 100644 --- a/src/sp/protocol/pubsub0/sub.c +++ b/src/sp/protocol/pubsub0/sub.c @@ -711,8 +711,7 @@ nng_sub0_socket_subscribe(nng_socket id, const void *buf, size_t sz) nni_sock *s; sub0_sock *sock; - if (((rv = nni_init()) != 0) || - ((rv = nni_sock_find(&s, id.id)) != 0)) { + if ((rv = nni_sock_find(&s, id.id)) != 0) { return (rv); } // validate the socket type @@ -733,8 +732,7 @@ nng_sub0_socket_unsubscribe(nng_socket id, const void *buf, size_t sz) nni_sock *s; sub0_sock *sock; - if (((rv = nni_init()) != 0) || - ((rv = nni_sock_find(&s, id.id)) != 0)) { + if ((rv = nni_sock_find(&s, id.id)) != 0) { return (rv); } // validate the socket type @@ -755,8 +753,7 @@ nng_sub0_ctx_subscribe(nng_ctx id, const void *buf, size_t sz) nni_ctx *c; sub0_ctx *ctx; - if (((rv = nni_init()) != 0) || - ((rv = nni_ctx_find(&c, id.id, false)) != 0)) { + if ((rv = nni_ctx_find(&c, id.id, false)) != 0) { return (rv); } // validate the socket type @@ -777,8 +774,7 @@ nng_sub0_ctx_unsubscribe(nng_ctx id, const void *buf, size_t sz) nni_ctx *c; sub0_ctx *ctx; - if (((rv = nni_init()) != 0) || - ((rv = nni_ctx_find(&c, id.id, false)) != 0)) { + if ((rv = nni_ctx_find(&c, id.id, false)) != 0) { return (rv); } // validate the socket type -- cgit v1.2.3-70-g09d2