aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/pubsub0/pub.c
diff options
context:
space:
mode:
authorNathan Kent <nate@nkent.net>2019-09-25 18:46:38 -0400
committerGarrett D'Amore <garrett@damore.org>2019-11-03 10:24:47 -0800
commit96b7677ddc8e49da045ca770703df065f10db280 (patch)
tree1302c0cf0298033bc408b1806a4c2260bb4b74b4 /src/protocol/pubsub0/pub.c
parent32d17517b87713e4d584555c35ac48d010243910 (diff)
downloadnng-96b7677ddc8e49da045ca770703df065f10db280.tar.gz
nng-96b7677ddc8e49da045ca770703df065f10db280.tar.bz2
nng-96b7677ddc8e49da045ca770703df065f10db280.zip
Add option for preferring new messages on SUB0
Diffstat (limited to 'src/protocol/pubsub0/pub.c')
-rw-r--r--src/protocol/pubsub0/pub.c9
1 files changed, 6 insertions, 3 deletions
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;