diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-09 23:45:21 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-11 11:03:12 -0800 |
| commit | 713b80f440cb414cd0b856bde0ea1b31f939777f (patch) | |
| tree | 1186c42418559c85719023bde3e919aa2df7fcef /src/core/socket.c | |
| parent | cbe9a27ef7485977fbc7c713376b096b6723da3d (diff) | |
| download | nng-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/socket.c')
| -rw-r--r-- | src/core/socket.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index 2b94e573..c92a1c3b 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -364,12 +364,9 @@ nni_sock_recvq(nni_sock *s) int nni_sock_find(nni_sock **sockp, uint32_t id) { - int rv; + int rv = 0; nni_sock *s; - if ((rv = nni_init()) != 0) { - return (rv); - } nni_mtx_lock(&sock_lk); if ((s = nni_id_get(&sock_ids, id)) != NULL) { if (s->s_closed) { @@ -621,8 +618,7 @@ nni_sock_open(nni_sock **sockp, const nni_proto *proto) return (NNG_ENOTSUP); } - if (((rv = nni_init()) != 0) || - ((rv = nni_sock_create(&s, proto)) != 0)) { + if ((rv = nni_sock_create(&s, proto)) != 0) { return (rv); } @@ -1076,12 +1072,9 @@ nni_sock_set_pipe_cb(nni_sock *s, int ev, nng_pipe_cb cb, void *arg) int nni_ctx_find(nni_ctx **cp, uint32_t id, bool closing) { - int rv; + int rv = 0; nni_ctx *ctx; - if ((rv = nni_init()) != 0) { - return (rv); - } nni_mtx_lock(&sock_lk); if ((ctx = nni_id_get(&ctx_ids, id)) != NULL) { // We refuse a reference if either the socket is |
