diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-19 10:33:11 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-21 13:52:18 -0700 |
| commit | b2c9baba988347c5bf15423f2ea40ce9d05da075 (patch) | |
| tree | af08f823cec5f5e0e8b68d380d49cc8c659cb7b8 /src/core | |
| parent | 6abb328523509d35663f54ee0012254232df4a0a (diff) | |
| download | nng-b2c9baba988347c5bf15423f2ea40ce9d05da075.tar.gz nng-b2c9baba988347c5bf15423f2ea40ce9d05da075.tar.bz2 nng-b2c9baba988347c5bf15423f2ea40ce9d05da075.zip | |
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.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/msgqueue.c | 11 |
1 files changed, 8 insertions, 3 deletions
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); } |
