aboutsummaryrefslogtreecommitdiff
path: root/src/core/msgqueue.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-03-06 01:12:00 -0800
committerGarrett D'Amore <garrett@damore.org>2017-03-06 01:12:00 -0800
commit44a6de38d240143ec2b4bb6f6457bae81271820a (patch)
tree0b0f330b515227f29d302d91f872c12e3d9a9395 /src/core/msgqueue.c
parent884da789532be511245248206adb00696ae62d31 (diff)
downloadnng-44a6de38d240143ec2b4bb6f6457bae81271820a.tar.gz
nng-44a6de38d240143ec2b4bb6f6457bae81271820a.tar.bz2
nng-44a6de38d240143ec2b4bb6f6457bae81271820a.zip
Pair protocol now callback driven.
Diffstat (limited to 'src/core/msgqueue.c')
-rw-r--r--src/core/msgqueue.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c
index dc3f84f9..147c0e20 100644
--- a/src/core/msgqueue.c
+++ b/src/core/msgqueue.c
@@ -517,11 +517,13 @@ nni_msgq_run_timeout(void *arg)
naio = nni_list_first(&mq->mq_aio_getq);
while ((aio = naio) != NULL) {
naio = nni_list_next(&mq->mq_aio_getq, aio);
- if (now >= aio->a_expire) {
+ if (aio->a_expire == NNI_TIME_ZERO) {
+ nni_list_remove(&mq->mq_aio_getq, aio);
+ nni_aio_finish(aio, NNG_EAGAIN, 0);
+ } else if (now >= aio->a_expire) {
nni_list_remove(&mq->mq_aio_getq, aio);
nni_aio_finish(aio, NNG_ETIMEDOUT, 0);
- }
- if (exp > aio->a_expire) {
+ } else if (exp > aio->a_expire) {
exp = aio->a_expire;
}
}
@@ -529,11 +531,13 @@ nni_msgq_run_timeout(void *arg)
naio = nni_list_first(&mq->mq_aio_putq);
while ((aio = naio) != NULL) {
naio = nni_list_next(&mq->mq_aio_putq, aio);
- if (now >= aio->a_expire) {
+ if (aio->a_expire == NNI_TIME_ZERO) {
+ nni_list_remove(&mq->mq_aio_putq, aio);
+ nni_aio_finish(aio, NNG_EAGAIN, 0);
+ } else if (now >= aio->a_expire) {
nni_list_remove(&mq->mq_aio_putq, aio);
nni_aio_finish(aio, NNG_ETIMEDOUT, 0);
- }
- if (exp > aio->a_expire) {
+ } else if (exp > aio->a_expire) {
exp = aio->a_expire;
}
}
@@ -748,6 +752,7 @@ nni_msgq_put_until(nni_msgq *mq, nni_msg *msg, nni_time expire)
aio.a_msg = msg;
nni_msgq_aio_put(mq, &aio);
nni_aio_wait(&aio);
+ rv = nni_aio_result(&aio);
nni_aio_fini(&aio);
return (rv);
}