From 6237d268514e1f8aec562052954db22c4540eec3 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 25 Dec 2021 17:38:14 -0800 Subject: 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.) --- src/sp/protocol/pair0/pair.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/sp/protocol/pair0') diff --git a/src/sp/protocol/pair0/pair.c b/src/sp/protocol/pair0/pair.c index c6470b7b..24c88d36 100644 --- a/src/sp/protocol/pair0/pair.c +++ b/src/sp/protocol/pair0/pair.c @@ -217,7 +217,7 @@ pair0_pipe_recv_cb(void *arg) // maybe we have room in the rmq? if (!nni_lmq_full(&s->rmq)) { - nni_lmq_putq(&s->rmq, msg); + nni_lmq_put(&s->rmq, msg); nni_aio_set_msg(&p->aio_recv, NULL); nni_pipe_recv(p->pipe, &p->aio_recv); } else { @@ -245,14 +245,14 @@ pair0_send_sched(pair0_sock *s) s->wr_ready = true; // if message waiting in buffered queue, then we prefer that. - if (nni_lmq_getq(&s->wmq, &m) == 0) { + if (nni_lmq_get(&s->wmq, &m) == 0) { pair0_pipe_send(p, m); if ((a = nni_list_first(&s->waq)) != NULL) { nni_aio_list_remove(a); m = nni_aio_get_msg(a); l = nni_msg_len(m); - nni_lmq_putq(&s->wmq, m); + nni_lmq_put(&s->wmq, m); } } else if ((a = nni_list_first(&s->waq)) != NULL) { @@ -311,8 +311,8 @@ pair0_sock_close(void *arg) nni_aio_list_remove(a); nni_aio_finish_error(a, NNG_ECLOSED); } - while ((nni_lmq_getq(&s->rmq, &m) == 0) || - (nni_lmq_getq(&s->wmq, &m) == 0)) { + while ((nni_lmq_get(&s->rmq, &m) == 0) || + (nni_lmq_get(&s->wmq, &m) == 0)) { nni_msg_free(m); } nni_mtx_unlock(&s->mtx); @@ -359,7 +359,7 @@ pair0_sock_send(void *arg, nni_aio *aio) } // Can we maybe queue it. - if (nni_lmq_putq(&s->wmq, m) == 0) { + if (nni_lmq_put(&s->wmq, m) == 0) { // Yay, we can. So we're done. nni_aio_set_msg(aio, NULL); nni_aio_finish(aio, 0, len); @@ -396,14 +396,14 @@ pair0_sock_recv(void *arg, nni_aio *aio) // Buffered read. If there is a message waiting for us, pick // it up. We might need to post another read request as well. - if (nni_lmq_getq(&s->rmq, &m) == 0) { + if (nni_lmq_get(&s->rmq, &m) == 0) { nni_aio_set_msg(aio, m); nni_aio_finish(aio, 0, nni_msg_len(m)); if (s->rd_ready) { s->rd_ready = false; m = nni_aio_get_msg(&p->aio_recv); nni_aio_set_msg(&p->aio_recv, NULL); - nni_lmq_putq(&s->rmq, m); + nni_lmq_put(&s->rmq, m); nni_pipe_recv(p->pipe, &p->aio_recv); } if (nni_lmq_empty(&s->rmq)) { -- cgit v1.2.3-70-g09d2