aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/pubsub0/sub.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-25 17:38:14 -0800
committerGarrett D'Amore <garrett@damore.org>2021-12-25 17:38:14 -0800
commit6237d268514e1f8aec562052954db22c4540eec3 (patch)
tree32213ea0016ae10faee2817f414308c91d881c42 /src/sp/protocol/pubsub0/sub.c
parent7a54bcd6fe345f35dd51eede6c5d66e8516c16ab (diff)
downloadnng-6237d268514e1f8aec562052954db22c4540eec3.tar.gz
nng-6237d268514e1f8aec562052954db22c4540eec3.tar.bz2
nng-6237d268514e1f8aec562052954db22c4540eec3.zip
Provide a tiny buf for lmq buffer by default.
This allows us to make nni_lmq_init() non-failing. (Although the buffer size requested at initialization might not be granted.)
Diffstat (limited to 'src/sp/protocol/pubsub0/sub.c')
-rw-r--r--src/sp/protocol/pubsub0/sub.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c
index a40ee073..35b32af4 100644
--- a/src/sp/protocol/pubsub0/sub.c
+++ b/src/sp/protocol/pubsub0/sub.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>
// Copyright 2019 Nathan Kent <nate@nkent.net>
//
@@ -115,7 +115,7 @@ again:
return;
}
- (void) nni_lmq_getq(&ctx->lmq, &msg);
+ (void) nni_lmq_get(&ctx->lmq, &msg);
if (nni_lmq_empty(&ctx->lmq) && (ctx == &sock->master)) {
nni_pollable_clear(&sock->readable);
@@ -182,15 +182,12 @@ sub0_ctx_init(void *ctx_arg, void *sock_arg)
sub0_ctx * ctx = ctx_arg;
size_t len;
bool prefer_new;
- int rv;
nni_mtx_lock(&sock->lk);
len = sock->recv_buf_len;
prefer_new = sock->prefer_new;
- if ((rv = nni_lmq_init(&ctx->lmq, len)) != 0) {
- return (rv);
- }
+ nni_lmq_init(&ctx->lmq, len);
ctx->prefer_new = prefer_new;
nni_aio_list_init(&ctx->recv_queue);
@@ -385,14 +382,14 @@ sub0_recv_cb(void *arg)
} else if (nni_lmq_full(&ctx->lmq)) {
// Make space for the new message.
nni_msg *old;
- (void) nni_lmq_getq(&ctx->lmq, &old);
+ (void) nni_lmq_get(&ctx->lmq, &old);
nni_msg_free(old);
- (void) nni_lmq_putq(&ctx->lmq, dup_msg);
+ (void) nni_lmq_put(&ctx->lmq, dup_msg);
queued = true;
} else {
- (void) nni_lmq_putq(&ctx->lmq, dup_msg);
+ (void) nni_lmq_put(&ctx->lmq, dup_msg);
queued = true;
}
if (queued && ctx == &sock->master) {
@@ -534,9 +531,9 @@ sub0_ctx_unsubscribe(void *arg, const void *buf, size_t sz, nni_type t)
for (size_t i = 0; i < len; i++) {
nni_msg *msg;
- (void) nni_lmq_getq(&ctx->lmq, &msg);
+ (void) nni_lmq_get(&ctx->lmq, &msg);
if (sub0_matches(ctx, nni_msg_body(msg), nni_msg_len(msg))) {
- (void) nni_lmq_putq(&ctx->lmq, msg);
+ (void) nni_lmq_put(&ctx->lmq, msg);
} else {
nni_msg_free(msg);
}