aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/protocol.h4
-rw-r--r--src/core/socket.c34
-rw-r--r--src/sp/protocol/bus0/bus.c8
-rw-r--r--src/sp/protocol/pair0/pair.c3
-rw-r--r--src/sp/protocol/pair1/pair.c18
-rw-r--r--src/sp/protocol/pair1/pair1_poly.c16
-rw-r--r--src/sp/protocol/pipeline0/pull.c5
-rw-r--r--src/sp/protocol/pipeline0/push.c6
-rw-r--r--src/sp/protocol/pubsub0/pub.c3
-rw-r--r--src/sp/protocol/pubsub0/sub.c18
-rw-r--r--src/sp/protocol/pubsub0/xsub.c5
-rw-r--r--src/sp/protocol/reqrep0/rep.c12
-rw-r--r--src/sp/protocol/reqrep0/req.c61
-rw-r--r--src/sp/protocol/reqrep0/xrep.c5
-rw-r--r--src/sp/protocol/reqrep0/xreq.c6
-rw-r--r--src/sp/protocol/survey0/respond.c13
-rw-r--r--src/sp/protocol/survey0/survey.c15
-rw-r--r--src/sp/protocol/survey0/xrespond.c12
-rw-r--r--src/sp/protocol/survey0/xsurvey.c6
19 files changed, 100 insertions, 150 deletions
diff --git a/src/core/protocol.h b/src/core/protocol.h
index a8645763..6118a2ac 100644
--- a/src/core/protocol.h
+++ b/src/core/protocol.h
@@ -63,7 +63,7 @@ struct nni_proto_ctx_ops {
// ctx_init initializes a new context. The second argument is the
// protocol specific socket structure.
- int (*ctx_init)(void *, void *);
+ void (*ctx_init)(void *, void *);
// ctx_fini destroys a context.
void (*ctx_fini)(void *);
@@ -85,7 +85,7 @@ struct nni_proto_sock_ops {
// sock_init initializes the protocol instance, which will be stored
// on the socket. This is run without the sock lock held.
- int (*sock_init)(void *, nni_sock *);
+ void (*sock_init)(void *, nni_sock *);
// sock_fini destroys the protocol instance. This is run without the
// socket lock held, and is intended to release resources. It may
diff --git a/src/core/socket.c b/src/core/socket.c
index a8850b5d..425499ae 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -577,25 +577,26 @@ nni_sock_create(nni_sock **sp, const nni_proto *proto)
#endif
if (((rv = nni_msgq_init(&s->s_uwq, 0)) != 0) ||
- ((rv = nni_msgq_init(&s->s_urq, 1)) != 0) ||
- ((rv = s->s_sock_ops.sock_init(s->s_data, s)) != 0) ||
- ((rv = nni_sock_setopt(s, NNG_OPT_SENDTIMEO, &s->s_sndtimeo,
- sizeof(nni_duration), NNI_TYPE_DURATION)) != 0) ||
- ((rv = nni_sock_setopt(s, NNG_OPT_RECVTIMEO, &s->s_rcvtimeo,
- sizeof(nni_duration), NNI_TYPE_DURATION)) != 0) ||
- ((rv = nni_sock_setopt(s, NNG_OPT_RECONNMINT, &s->s_reconn,
- sizeof(nni_duration), NNI_TYPE_DURATION)) != 0) ||
- ((rv = nni_sock_setopt(s, NNG_OPT_RECONNMAXT, &s->s_reconnmax,
- sizeof(nni_duration), NNI_TYPE_DURATION)) != 0) ||
- ((rv = nni_sock_setopt(s, NNG_OPT_RECVMAXSZ, &s->s_rcvmaxsz,
- sizeof(size_t), NNI_TYPE_SIZE)) != 0)) {
+ ((rv = nni_msgq_init(&s->s_urq, 1)) != 0)) {
sock_destroy(s);
return (rv);
}
+ s->s_sock_ops.sock_init(s->s_data, s);
- // These we *attempt* to call so that we are likely to have initial
+ // These we *attempt* to set so that we are likely to have initial
// values loaded. They should not fail, but if they do we don't
// worry about it.
+ (void) nni_sock_setopt(s, NNG_OPT_SENDTIMEO, &s->s_sndtimeo,
+ sizeof(nni_duration), NNI_TYPE_DURATION);
+ (void) nni_sock_setopt(s, NNG_OPT_RECVTIMEO, &s->s_rcvtimeo,
+ sizeof(nni_duration), NNI_TYPE_DURATION);
+ (void) nni_sock_setopt(s, NNG_OPT_RECONNMINT, &s->s_reconn,
+ sizeof(nni_duration), NNI_TYPE_DURATION);
+ (void) nni_sock_setopt(s, NNG_OPT_RECONNMAXT, &s->s_reconnmax,
+ sizeof(nni_duration), NNI_TYPE_DURATION);
+ (void) nni_sock_setopt(s, NNG_OPT_RECVMAXSZ, &s->s_rcvmaxsz,
+ sizeof(size_t), NNI_TYPE_SIZE);
+
on = true;
(void) nni_sock_setopt(
s, NNG_OPT_TCP_NODELAY, &on, sizeof(on), NNI_TYPE_BOOL);
@@ -1292,12 +1293,7 @@ nni_ctx_open(nni_ctx **ctxp, nni_sock *sock)
return (rv);
}
- if ((rv = sock->s_ctx_ops.ctx_init(ctx->c_data, sock->s_data)) != 0) {
- nni_id_remove(&ctx_ids, ctx->c_id);
- nni_mtx_unlock(&sock_lk);
- nni_free(ctx, ctx->c_size);
- return (rv);
- }
+ sock->s_ctx_ops.ctx_init(ctx->c_data, sock->s_data);
nni_list_append(&sock->s_ctxs, ctx);
nni_mtx_unlock(&sock_lk);
diff --git a/src/sp/protocol/bus0/bus.c b/src/sp/protocol/bus0/bus.c
index 5ec393ba..ab857d72 100644
--- a/src/sp/protocol/bus0/bus.c
+++ b/src/sp/protocol/bus0/bus.c
@@ -72,7 +72,7 @@ bus0_sock_fini(void *arg)
nni_mtx_fini(&s->mtx);
}
-static int
+static void
bus0_sock_init(void *arg, nni_sock *nsock)
{
bus0_sock *s = arg;
@@ -83,11 +83,9 @@ bus0_sock_init(void *arg, nni_sock *nsock)
s->uwq = nni_sock_sendq(nsock);
s->urq = nni_sock_recvq(nsock);
s->raw = false;
-
- return (0);
}
-static int
+static void
bus0_sock_init_raw(void *arg, nni_sock *nsock)
{
bus0_sock *s = arg;
@@ -98,8 +96,6 @@ bus0_sock_init_raw(void *arg, nni_sock *nsock)
s->uwq = nni_sock_sendq(nsock);
s->urq = nni_sock_recvq(nsock);
s->raw = true;
-
- return (0);
}
static void
diff --git a/src/sp/protocol/pair0/pair.c b/src/sp/protocol/pair0/pair.c
index 24c88d36..4abeb16a 100644
--- a/src/sp/protocol/pair0/pair.c
+++ b/src/sp/protocol/pair0/pair.c
@@ -55,7 +55,7 @@ struct pair0_pipe {
nni_aio aio_recv;
};
-static int
+static void
pair0_sock_init(void *arg, nni_sock *sock)
{
pair0_sock *s = arg;
@@ -71,7 +71,6 @@ pair0_sock_init(void *arg, nni_sock *sock)
nni_pollable_init(&s->readable);
s->p = NULL;
- return (0);
}
static void
diff --git a/src/sp/protocol/pair1/pair.c b/src/sp/protocol/pair1/pair.c
index 636e51e9..e98e1ed9 100644
--- a/src/sp/protocol/pair1/pair.c
+++ b/src/sp/protocol/pair1/pair.c
@@ -91,7 +91,7 @@ pair1_add_sock_stat(
}
#endif
-static int
+static void
pair1_sock_init_impl(void *arg, nni_sock *sock, bool raw)
{
pair1_sock *s = arg;
@@ -179,20 +179,18 @@ pair1_sock_init_impl(void *arg, nni_sock *sock, bool raw)
nni_stat_set_bool(&s->stat_raw, raw);
nni_stat_set_bool(&s->stat_poly, false);
#endif
-
- return (0);
}
-static int
+static void
pair1_sock_init(void *arg, nni_sock *sock)
{
- return (pair1_sock_init_impl(arg, sock, false));
+ pair1_sock_init_impl(arg, sock, false);
}
-static int
+static void
pair1_sock_init_raw(void *arg, nni_sock *sock)
{
- return (pair1_sock_init_impl(arg, sock, true));
+ pair1_sock_init_impl(arg, sock, true);
}
static void
@@ -540,7 +538,7 @@ pair1_sock_send(void *arg, nni_aio *aio)
#endif
// Raw mode messages have the header already formed, with a hop count.
- // Cooked mode messages have no header so we have to add one.
+ // Cooked mode messages have no header, so we have to add one.
if (s->raw) {
if ((nni_msg_header_len(m) != sizeof(uint32_t)) ||
(nni_msg_header_peek_u32(m) >= 0xff)) {
@@ -551,7 +549,7 @@ pair1_sock_send(void *arg, nni_aio *aio)
} else {
// Strip off any previously existing header, such as when
- // replying to messages.
+ // replying to a message.
nni_msg_header_clear(m);
nni_msg_header_append_u32(m, 0);
}
@@ -573,7 +571,7 @@ inject:
return;
}
- // Can we maybe queue it.
+ // Can we queue it?
if (nni_lmq_put(&s->wmq, m) == 0) {
// Yay, we can. So we're done.
nni_aio_set_msg(aio, NULL);
diff --git a/src/sp/protocol/pair1/pair1_poly.c b/src/sp/protocol/pair1/pair1_poly.c
index 6c16745c..06afc57a 100644
--- a/src/sp/protocol/pair1/pair1_poly.c
+++ b/src/sp/protocol/pair1/pair1_poly.c
@@ -13,9 +13,9 @@
#include "core/nng_impl.h"
#include "nng/protocol/pair1/pair.h"
-// Pair1 polyamorous mode. The PAIRv1 protocol is normally a simple 1:1
+// Pair1 poly-amorous mode. The PAIRv1 protocol is normally a simple 1:1
// messaging pattern, but this mode offers the ability to use a best-effort
-// multicast type of communication. There are limitations however.
+// multicast type of communication. There are limitations, however.
// Most notably this does not interact well with nng_device type
// proxies, and there is no support for raw mode.
@@ -90,7 +90,7 @@ pair1_add_sock_stat(
}
#endif
-static int
+static void
pair1poly_sock_init(void *arg, nni_sock *sock)
{
pair1poly_sock *s = arg;
@@ -173,8 +173,6 @@ pair1poly_sock_init(void *arg, nni_sock *sock)
s->urq = nni_sock_recvq(sock);
nni_atomic_init(&s->ttl);
nni_atomic_set(&s->ttl, 8);
-
- return (0);
}
static void
@@ -250,7 +248,7 @@ pair1poly_pipe_start(void *arg)
s->started = true;
nni_mtx_unlock(&s->mtx);
- // Schedule a get. In polyamorous mode we get on the per pipe
+ // Schedule a get. In poly-amorous mode we get on the per pipe
// send_queue, as the socket distributes to us. In monogamous mode
// we bypass and get from the upper write queue directly (saving a
// set of context switches).
@@ -398,12 +396,12 @@ pair1poly_pipe_get_cb(void *arg)
msg = nni_aio_get_msg(&p->aio_get);
nni_aio_set_msg(&p->aio_get, NULL);
- // Cooked mode messages have no header so we have to add one.
+ // Cooked mode messages have no header, so we have to add one.
// Strip off any previously existing header, such as when
- // replying to messages.
+ // replying to a message.
nni_msg_header_clear(msg);
- // Insert the hops header.
+ // Insert the hop count header.
nni_msg_header_append_u32(msg, 1);
nni_aio_set_msg(&p->aio_send, msg);
diff --git a/src/sp/protocol/pipeline0/pull.c b/src/sp/protocol/pipeline0/pull.c
index 616b0817..07d55405 100644
--- a/src/sp/protocol/pipeline0/pull.c
+++ b/src/sp/protocol/pipeline0/pull.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
@@ -47,7 +47,7 @@ struct pull0_pipe {
nni_list_node node;
};
-static int
+static void
pull0_sock_init(void *arg, nni_sock *sock)
{
pull0_sock *s = arg;
@@ -57,7 +57,6 @@ pull0_sock_init(void *arg, nni_sock *sock)
NNI_LIST_INIT(&s->pl, pull0_pipe, node);
nni_mtx_init(&s->m);
nni_pollable_init(&s->readable);
- return (0);
}
static void
diff --git a/src/sp/protocol/pipeline0/push.c b/src/sp/protocol/pipeline0/push.c
index 99cb2da4..09953ccf 100644
--- a/src/sp/protocol/pipeline0/push.c
+++ b/src/sp/protocol/pipeline0/push.c
@@ -51,7 +51,7 @@ struct push0_pipe {
nni_aio aio_send;
};
-static int
+static void
push0_sock_init(void *arg, nni_sock *sock)
{
push0_sock *s = arg;
@@ -62,8 +62,6 @@ push0_sock_init(void *arg, nni_sock *sock)
NNI_LIST_INIT(&s->pl, push0_pipe, node);
nni_lmq_init(&s->wq, 0); // initially we start unbuffered.
nni_pollable_init(&s->writable);
-
- return (0);
}
static void
@@ -299,7 +297,7 @@ push0_sock_send(void *arg, nni_aio *aio)
return;
}
- // Can we maybe queue it.
+ // Can we queue it?
if (nni_lmq_put(&s->wq, m) == 0) {
// Yay, we can. So we're done.
nni_aio_set_msg(aio, NULL);
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
diff --git a/src/sp/protocol/reqrep0/rep.c b/src/sp/protocol/reqrep0/rep.c
index aa32d249..a15488c0 100644
--- a/src/sp/protocol/reqrep0/rep.c
+++ b/src/sp/protocol/reqrep0/rep.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
@@ -93,7 +93,7 @@ rep0_ctx_fini(void *arg)
rep0_ctx_close(ctx);
}
-static int
+static void
rep0_ctx_init(void *carg, void *sarg)
{
rep0_sock *s = sarg;
@@ -104,8 +104,6 @@ rep0_ctx_init(void *carg, void *sarg)
ctx->btrace_len = 0;
ctx->sock = s;
ctx->pipe_id = 0;
-
- return (0);
}
static void
@@ -217,7 +215,7 @@ rep0_sock_fini(void *arg)
nni_mtx_fini(&s->lk);
}
-static int
+static void
rep0_sock_init(void *arg, nni_sock *sock)
{
rep0_sock *s = arg;
@@ -231,14 +229,12 @@ rep0_sock_init(void *arg, nni_sock *sock)
nni_atomic_init(&s->ttl);
nni_atomic_set(&s->ttl, 8);
- (void) rep0_ctx_init(&s->ctx, s);
+ rep0_ctx_init(&s->ctx, s);
// We start off without being either readable or writable.
// Readability comes when there is something on the socket.
nni_pollable_init(&s->writable);
nni_pollable_init(&s->readable);
-
- return (0);
}
static void
diff --git a/src/sp/protocol/reqrep0/req.c b/src/sp/protocol/reqrep0/req.c
index cb3c9395..ecea9fbd 100644
--- a/src/sp/protocol/reqrep0/req.c
+++ b/src/sp/protocol/reqrep0/req.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
@@ -24,22 +24,22 @@ static void req0_ctx_reset(req0_ctx *);
static void req0_ctx_timeout(void *);
static void req0_pipe_fini(void *);
static void req0_ctx_fini(void *);
-static int req0_ctx_init(void *, void *);
+static void req0_ctx_init(void *, void *);
// A req0_ctx is a "context" for the request. It uses most of the
// socket, but keeps track of its own outstanding replays, the request ID,
// and so forth.
struct req0_ctx {
- req0_sock * sock;
+ req0_sock *sock;
nni_list_node sock_node; // node on the socket context list
nni_list_node send_node; // node on the send_queue
nni_list_node pipe_node; // node on the pipe list
uint32_t request_id; // request ID, without high bit set
- nni_aio * recv_aio; // user aio waiting to recv - only one!
- nni_aio * send_aio; // user aio waiting to send
- nng_msg * req_msg; // request message (owned by protocol)
+ nni_aio *recv_aio; // user aio waiting to recv - only one!
+ nni_aio *send_aio; // user aio waiting to send
+ nng_msg *req_msg; // request message (owned by protocol)
size_t req_len; // length of request message (for stats)
- nng_msg * rep_msg; // reply message
+ nng_msg *rep_msg; // reply message
nni_timer_node timer;
nni_duration retry;
bool conn_reset; // sent message w/o retry, peer disconnect
@@ -64,8 +64,8 @@ struct req0_sock {
// A req0_pipe is our per-pipe protocol private structure.
struct req0_pipe {
- nni_pipe * pipe;
- req0_sock * req;
+ nni_pipe *pipe;
+ req0_sock *req;
nni_list_node node;
nni_list contexts; // contexts with pending traffic
bool closed;
@@ -77,7 +77,7 @@ static void req0_sock_fini(void *);
static void req0_send_cb(void *);
static void req0_recv_cb(void *);
-static int
+static void
req0_sock_init(void *arg, nni_sock *sock)
{
req0_sock *s = arg;
@@ -100,14 +100,13 @@ req0_sock_init(void *arg, nni_sock *sock)
// this is "semi random" start for request IDs.
s->retry = NNI_SECOND * 60;
- (void) req0_ctx_init(&s->master, s);
+ req0_ctx_init(&s->master, s);
nni_pollable_init(&s->writable);
nni_pollable_init(&s->readable);
nni_atomic_init(&s->ttl);
nni_atomic_set(&s->ttl, 8);
- return (0);
}
static void
@@ -205,7 +204,7 @@ req0_pipe_close(void *arg)
{
req0_pipe *p = arg;
req0_sock *s = p->req;
- req0_ctx * ctx;
+ req0_ctx *ctx;
nni_aio_close(&p->aio_recv);
nni_aio_close(&p->aio_send);
@@ -231,7 +230,7 @@ req0_pipe_close(void *arg)
if ((aio = ctx->recv_aio) != NULL) {
ctx->recv_aio = NULL;
nni_aio_finish_error(aio, NNG_ECONNRESET);
- req0_ctx_reset(ctx);
+ req0_ctx_reset(ctx);
} else {
req0_ctx_reset(ctx);
ctx->conn_reset = true;
@@ -258,7 +257,7 @@ req0_send_cb(void *arg)
{
req0_pipe *p = arg;
req0_sock *s = p->req;
- nni_aio * aio;
+ nni_aio *aio;
nni_list sent_list;
nni_aio_list_init(&sent_list);
@@ -299,9 +298,9 @@ req0_recv_cb(void *arg)
{
req0_pipe *p = arg;
req0_sock *s = p->req;
- req0_ctx * ctx;
- nni_msg * msg;
- nni_aio * aio;
+ req0_ctx *ctx;
+ nni_msg *msg;
+ nni_aio *aio;
uint32_t id;
if (nni_aio_result(&p->aio_recv) != 0) {
@@ -370,7 +369,7 @@ malformed:
static void
req0_ctx_timeout(void *arg)
{
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
req0_sock *s = ctx->sock;
nni_mtx_lock(&s->mtx);
@@ -383,11 +382,11 @@ req0_ctx_timeout(void *arg)
nni_mtx_unlock(&s->mtx);
}
-static int
+static void
req0_ctx_init(void *arg, void *sock)
{
req0_sock *s = sock;
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
nni_timer_init(&ctx->timer, req0_ctx_timeout, ctx);
@@ -397,16 +396,14 @@ req0_ctx_init(void *arg, void *sock)
ctx->retry = s->retry;
nni_list_append(&s->contexts, ctx);
nni_mtx_unlock(&s->mtx);
-
- return (0);
}
static void
req0_ctx_fini(void *arg)
{
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
req0_sock *s = ctx->sock;
- nni_aio * aio;
+ nni_aio *aio;
nni_mtx_lock(&s->mtx);
if ((aio = ctx->recv_aio) != NULL) {
@@ -445,7 +442,7 @@ static void
req0_run_send_queue(req0_sock *s, nni_list *sent_list)
{
req0_ctx *ctx;
- nni_aio * aio;
+ nni_aio *aio;
// Note: This routine should be called with the socket lock held.
while ((ctx = nni_list_first(&s->send_queue)) != NULL) {
@@ -540,7 +537,7 @@ req0_ctx_reset(req0_ctx *ctx)
static void
req0_ctx_cancel_recv(nni_aio *aio, void *arg, int rv)
{
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
req0_sock *s = ctx->sock;
nni_mtx_lock(&s->mtx);
@@ -564,9 +561,9 @@ req0_ctx_cancel_recv(nni_aio *aio, void *arg, int rv)
static void
req0_ctx_recv(void *arg, nni_aio *aio)
{
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
req0_sock *s = ctx->sock;
- nni_msg * msg;
+ nni_msg *msg;
if (nni_aio_begin(aio) != 0) {
return;
@@ -616,7 +613,7 @@ req0_ctx_recv(void *arg, nni_aio *aio)
static void
req0_ctx_cancel_send(nni_aio *aio, void *arg, int rv)
{
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
req0_sock *s = ctx->sock;
nni_mtx_lock(&s->mtx);
@@ -647,9 +644,9 @@ req0_ctx_cancel_send(nni_aio *aio, void *arg, int rv)
static void
req0_ctx_send(void *arg, nni_aio *aio)
{
- req0_ctx * ctx = arg;
+ req0_ctx *ctx = arg;
req0_sock *s = ctx->sock;
- nng_msg * msg = nni_aio_get_msg(aio);
+ nng_msg *msg = nni_aio_get_msg(aio);
int rv;
if (nni_aio_begin(aio) != 0) {
diff --git a/src/sp/protocol/reqrep0/xrep.c b/src/sp/protocol/reqrep0/xrep.c
index 9737c600..9241dccd 100644
--- a/src/sp/protocol/reqrep0/xrep.c
+++ b/src/sp/protocol/reqrep0/xrep.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
@@ -58,7 +58,7 @@ xrep0_sock_fini(void *arg)
nni_mtx_fini(&s->lk);
}
-static int
+static void
xrep0_sock_init(void *arg, nni_sock *sock)
{
xrep0_sock *s = arg;
@@ -71,7 +71,6 @@ xrep0_sock_init(void *arg, nni_sock *sock)
s->urq = nni_sock_recvq(sock);
nni_id_map_init(&s->pipes, 0, 0, false);
- return (0);
}
static void
diff --git a/src/sp/protocol/reqrep0/xreq.c b/src/sp/protocol/reqrep0/xreq.c
index bcb218bf..787c230d 100644
--- a/src/sp/protocol/reqrep0/xreq.c
+++ b/src/sp/protocol/reqrep0/xreq.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
@@ -42,7 +42,7 @@ static void xreq0_send_cb(void *);
static void xreq0_recv_cb(void *);
static void xreq0_putq_cb(void *);
-static int
+static void
xreq0_sock_init(void *arg, nni_sock *sock)
{
xreq0_sock *s = arg;
@@ -51,8 +51,6 @@ xreq0_sock_init(void *arg, nni_sock *sock)
nni_atomic_set(&s->ttl, 8);
s->uwq = nni_sock_sendq(sock);
s->urq = nni_sock_recvq(sock);
-
- return (0);
}
static void
diff --git a/src/sp/protocol/survey0/respond.c b/src/sp/protocol/survey0/respond.c
index ad551c8f..d29eab97 100644
--- a/src/sp/protocol/survey0/respond.c
+++ b/src/sp/protocol/survey0/respond.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
@@ -104,7 +104,7 @@ resp0_ctx_fini(void *arg)
resp0_ctx_close(ctx);
}
-static int
+static void
resp0_ctx_init(void *carg, void *sarg)
{
resp0_sock *s = sarg;
@@ -115,8 +115,6 @@ resp0_ctx_init(void *carg, void *sarg)
ctx->btrace_len = 0;
ctx->sock = s;
ctx->pipe_id = 0;
-
- return (0);
}
static void
@@ -220,7 +218,7 @@ resp0_sock_fini(void *arg)
nni_mtx_fini(&s->mtx);
}
-static int
+static void
resp0_sock_init(void *arg, nni_sock *nsock)
{
resp0_sock *s = arg;
@@ -236,13 +234,12 @@ resp0_sock_init(void *arg, nni_sock *nsock)
nni_atomic_init(&s->ttl);
nni_atomic_set(&s->ttl, 8); // Per RFC
- (void) resp0_ctx_init(&s->ctx, s);
+ resp0_ctx_init(&s->ctx, s);
// We start off without being either readable or writable.
// Readability comes when there is something on the socket.
nni_pollable_init(&s->writable);
nni_pollable_init(&s->readable);
- return (0);
}
static void
@@ -492,7 +489,7 @@ resp0_pipe_recv_cb(void *arg)
// Move backtrace from body to header
hops = 1;
for (;;) {
- bool end = 0;
+ bool end;
uint8_t *body;
if (hops > ttl) {
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
diff --git a/src/sp/protocol/survey0/xrespond.c b/src/sp/protocol/survey0/xrespond.c
index b2f203c3..81a40486 100644
--- a/src/sp/protocol/survey0/xrespond.c
+++ b/src/sp/protocol/survey0/xrespond.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
@@ -67,8 +67,8 @@ xresp0_sock_fini(void *arg)
nni_mtx_fini(&s->mtx);
}
-static int
-xresp0_sock_init(void *arg, nni_sock *nsock)
+static void
+xresp0_sock_init(void *arg, nni_sock *ns)
{
xresp0_sock *s = arg;
@@ -78,10 +78,8 @@ xresp0_sock_init(void *arg, nni_sock *nsock)
nni_id_map_init(&s->pipes, 0, 0, false);
nni_aio_init(&s->aio_getq, xresp0_sock_getq_cb, s);
- s->urq = nni_sock_recvq(nsock);
- s->uwq = nni_sock_sendq(nsock);
-
- return (0);
+ s->urq = nni_sock_recvq(ns);
+ s->uwq = nni_sock_sendq(ns);
}
static void
diff --git a/src/sp/protocol/survey0/xsurvey.c b/src/sp/protocol/survey0/xsurvey.c
index 2a198662..3cb3b6bd 100644
--- a/src/sp/protocol/survey0/xsurvey.c
+++ b/src/sp/protocol/survey0/xsurvey.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
@@ -54,7 +54,7 @@ xsurv0_sock_fini(void *arg)
nni_mtx_fini(&s->mtx);
}
-static int
+static void
xsurv0_sock_init(void *arg, nni_sock *nsock)
{
xsurv0_sock *s = arg;
@@ -67,8 +67,6 @@ xsurv0_sock_init(void *arg, nni_sock *nsock)
s->urq = nni_sock_recvq(nsock);
nni_atomic_init(&s->ttl);
nni_atomic_set(&s->ttl, 8);
-
- return (0);
}
static void