diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-12-25 18:01:49 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-12-25 18:05:56 -0800 |
| commit | 7b02ddc2d7077439992a10bb69553f89b5ee5903 (patch) | |
| tree | c3c6467330be2b38491f0df061d7016e713b1892 /src/sp/protocol/pubsub0 | |
| parent | 6237d268514e1f8aec562052954db22c4540eec3 (diff) | |
| download | nng-7b02ddc2d7077439992a10bb69553f89b5ee5903.tar.gz nng-7b02ddc2d7077439992a10bb69553f89b5ee5903.tar.bz2 nng-7b02ddc2d7077439992a10bb69553f89b5ee5903.zip | |
Socket and context initialization never fails.
This makes these functions entirely bullet proof, and eliminates
yet more error handling cases.
Diffstat (limited to 'src/sp/protocol/pubsub0')
| -rw-r--r-- | src/sp/protocol/pubsub0/pub.c | 3 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/sub.c | 18 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/xsub.c | 5 |
3 files changed, 8 insertions, 18 deletions
diff --git a/src/sp/protocol/pubsub0/pub.c b/src/sp/protocol/pubsub0/pub.c index 3911127a..b0a9ef07 100644 --- a/src/sp/protocol/pubsub0/pub.c +++ b/src/sp/protocol/pubsub0/pub.c @@ -64,7 +64,7 @@ pub0_sock_fini(void *arg) nni_mtx_fini(&s->mtx); } -static int +static void pub0_sock_init(void *arg, nni_sock *ns) { pub0_sock *sock = arg; @@ -74,7 +74,6 @@ pub0_sock_init(void *arg, nni_sock *ns) nni_mtx_init(&sock->mtx); NNI_LIST_INIT(&sock->pipes, pub0_pipe, node); sock->sendbuf = 16; // fairly arbitrary - return (0); } static void diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c index 35b32af4..10f42724 100644 --- a/src/sp/protocol/pubsub0/sub.c +++ b/src/sp/protocol/pubsub0/sub.c @@ -27,7 +27,7 @@ #define NNI_PROTO_PUB_V0 NNI_PROTO(2, 0) #endif -// By default we accept 128 messages. +// By default, we accept 128 messages. #define SUB0_DEFAULT_RECV_BUF_LEN 128 // By default, prefer new messages when the queue is full. @@ -175,7 +175,7 @@ sub0_ctx_fini(void *arg) nni_lmq_fini(&ctx->lmq); } -static int +static void sub0_ctx_init(void *ctx_arg, void *sock_arg) { sub0_sock *sock = sock_arg; @@ -198,8 +198,6 @@ sub0_ctx_init(void *ctx_arg, void *sock_arg) nni_list_append(&sock->contexts, ctx); sock->num_contexts++; nni_mtx_unlock(&sock->lk); - - return (0); } static void @@ -212,11 +210,10 @@ sub0_sock_fini(void *arg) nni_mtx_fini(&sock->lk); } -static int +static void sub0_sock_init(void *arg, nni_sock *unused) { sub0_sock *sock = arg; - int rv; NNI_ARG_UNUSED(unused); @@ -226,12 +223,7 @@ sub0_sock_init(void *arg, nni_sock *unused) sock->prefer_new = SUB0_DEFAULT_PREFER_NEW; nni_pollable_init(&sock->readable); - if ((rv = sub0_ctx_init(&sock->master, sock)) != 0) { - sub0_sock_fini(sock); - return (rv); - } - - return (0); + sub0_ctx_init(&sock->master, sock); } static void @@ -456,7 +448,7 @@ sub0_ctx_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) return (0); } -// For now we maintain subscriptions on a sorted linked list. As we do not +// For now, we maintain subscriptions on a sorted linked list. As we do not // expect to have huge numbers of subscriptions, and as the operation is // really O(n), we think this is acceptable. In the future we might decide // to replace this with a patricia trie, like old nanomsg had. diff --git a/src/sp/protocol/pubsub0/xsub.c b/src/sp/protocol/pubsub0/xsub.c index 0013b8b3..ad060087 100644 --- a/src/sp/protocol/pubsub0/xsub.c +++ b/src/sp/protocol/pubsub0/xsub.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -44,13 +44,12 @@ struct xsub0_pipe { nni_aio aio_recv; }; -static int +static void xsub0_sock_init(void *arg, nni_sock *sock) { xsub0_sock *s = arg; s->urq = nni_sock_recvq(sock); - return (0); } static void |
