aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/survey0/survey.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-25 18:01:49 -0800
committerGarrett D'Amore <garrett@damore.org>2021-12-25 18:05:56 -0800
commit7b02ddc2d7077439992a10bb69553f89b5ee5903 (patch)
treec3c6467330be2b38491f0df061d7016e713b1892 /src/sp/protocol/survey0/survey.c
parent6237d268514e1f8aec562052954db22c4540eec3 (diff)
downloadnng-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/survey0/survey.c')
-rw-r--r--src/sp/protocol/survey0/survey.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/sp/protocol/survey0/survey.c b/src/sp/protocol/survey0/survey.c
index 3287138d..5c52d8f8 100644
--- a/src/sp/protocol/survey0/survey.c
+++ b/src/sp/protocol/survey0/survey.c
@@ -103,7 +103,7 @@ surv0_ctx_fini(void *arg)
nni_lmq_fini(&ctx->recv_lmq);
}
-static int
+static void
surv0_ctx_init(void *c, void *s)
{
surv0_ctx * ctx = c;
@@ -130,7 +130,6 @@ surv0_ctx_init(void *c, void *s)
nni_lmq_init(&ctx->recv_lmq, len);
nni_timer_init(&ctx->timer, surv0_ctx_timeout, ctx);
- return (0);
}
static void
@@ -280,11 +279,10 @@ surv0_sock_fini(void *arg)
nni_mtx_fini(&sock->mtx);
}
-static int
+static void
surv0_sock_init(void *arg, nni_sock *s)
{
surv0_sock *sock = arg;
- int rv;
NNI_ARG_UNUSED(s);
@@ -295,7 +293,7 @@ surv0_sock_init(void *arg, nni_sock *s)
// We are always writable.
nni_pollable_raise(&sock->writable);
- // We allow for some buffering on a per pipe basis, to allow for
+ // We allow for some buffering on a per-pipe basis, to allow for
// multiple contexts to have surveys outstanding. It is recommended
// to increase this if many contexts will want to publish
// at nearly the same time.
@@ -307,14 +305,9 @@ surv0_sock_init(void *arg, nni_sock *s)
// accidental collision across restarts.
nni_id_map_init(&sock->surveys, 0x80000000u, 0xffffffffu, true);
- if ((rv = surv0_ctx_init(&sock->ctx, sock)) != 0) {
- surv0_sock_fini(sock);
- return (rv);
- }
+ surv0_ctx_init(&sock->ctx, sock);
sock->ttl = 8;
-
- return (0);
}
static void