From 96b7677ddc8e49da045ca770703df065f10db280 Mon Sep 17 00:00:00 2001 From: Nathan Kent Date: Wed, 25 Sep 2019 18:46:38 -0400 Subject: Add option for preferring new messages on SUB0 --- src/protocol/pubsub0/pub.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/protocol/pubsub0/pub.c') diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c index be550439..c54274a6 100644 --- a/src/protocol/pubsub0/pub.c +++ b/src/protocol/pubsub0/pub.c @@ -267,9 +267,6 @@ pub0_sock_send(void *arg, nni_aio *aio) if (p->closed) { continue; } - if (nni_lmq_full(&p->sendq)) { - continue; - } if (p == nni_list_last(&sock->pipes)) { dup = msg; msg = NULL; @@ -277,6 +274,12 @@ pub0_sock_send(void *arg, nni_aio *aio) continue; } if (p->busy) { + if (nni_lmq_full(&p->sendq)) { + // Make space for the new message. + nni_msg * old; + (void) nni_lmq_getq(&p->sendq, &old); + nni_msg_free(old); + } nni_lmq_putq(&p->sendq, dup); } else { p->busy = true; -- cgit v1.2.3-70-g09d2