From b2c9baba988347c5bf15423f2ea40ce9d05da075 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 19 May 2018 10:33:11 -0700 Subject: fixes #459 SUB should be more aggressive about discarding messages As part of this code fix, we needed to add filtering support to the msgq_tryput code path -- it turns out that code path was bypassing the filterfn altogether. Eventually we'll remove all this filtering stuff from the msgq code and replace it with inline filtering directly in sub. --- src/core/msgqueue.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/core/msgqueue.c') diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c index fa94e32f..62f57553 100644 --- a/src/core/msgqueue.c +++ b/src/core/msgqueue.c @@ -403,10 +403,15 @@ nni_msgq_tryput(nni_msgq *mq, nni_msg *msg) // the queue is empty, otherwise it would have just taken // data from the queue. if ((raio = nni_list_first(&mq->mq_aio_getq)) != NULL) { - nni_list_remove(&mq->mq_aio_getq, raio); - nni_aio_finish_msg(raio, msg); - nni_msgq_run_notify(mq); + if (mq->mq_filter_fn != NULL) { + msg = mq->mq_filter_fn(mq->mq_filter_arg, msg); + } + if (msg != NULL) { + nni_list_remove(&mq->mq_aio_getq, raio); + nni_aio_finish_msg(raio, msg); + nni_msgq_run_notify(mq); + } nni_mtx_unlock(&mq->mq_lock); return (0); } -- cgit v1.2.3-70-g09d2