diff options
| -rw-r--r-- | src/core/msgqueue.c | 2 | ||||
| -rw-r--r-- | src/core/pipe.c | 6 | ||||
| -rw-r--r-- | src/protocol/survey/respond.c | 5 | ||||
| -rw-r--r-- | tests/survey.c | 8 |
4 files changed, 12 insertions, 9 deletions
diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c index 344798d7..5f4bd333 100644 --- a/src/core/msgqueue.c +++ b/src/core/msgqueue.c @@ -466,7 +466,7 @@ nni_msgq_drain(nni_msgq *mq, nni_time expire) nni_cv_wake(&mq->mq_writeable); nni_cv_wake(&mq->mq_readable); while (mq->mq_len > 0) { - if (nni_cv_until(&mq->mq_drained, expire) == NNG_ETIMEDOUT) { + if (nni_cv_until(&mq->mq_drained, expire) != 0) { break; } } diff --git a/src/core/pipe.c b/src/core/pipe.c index a1a423e7..39b4d012 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -187,6 +187,7 @@ nni_pipe_start(nni_pipe *pipe) nni_mtx_lock(nni_idlock); rv = nni_idhash_alloc(nni_pipes, &pipe->p_id, pipe); nni_mtx_unlock(nni_idlock); + if (rv != 0) { nni_pipe_bail(pipe); nni_mtx_unlock(&sock->s_mx); @@ -196,19 +197,20 @@ nni_pipe_start(nni_pipe *pipe) if ((rv = sock->s_pipe_ops.pipe_add(pipe->p_proto_data)) != 0) { nni_mtx_lock(nni_idlock); nni_idhash_remove(nni_pipes, pipe->p_id); - nni_mtx_unlock(nni_idlock); pipe->p_id = 0; + nni_mtx_unlock(nni_idlock); + nni_pipe_bail(pipe); nni_mtx_unlock(&sock->s_mx); return (rv); } + pipe->p_active = 1; nni_list_append(&sock->s_pipes, pipe); for (i = 0; i < NNI_MAXWORKERS; i++) { nni_thr_run(&pipe->p_worker_thr[i]); } - pipe->p_active = 1; // XXX: Publish event diff --git a/src/protocol/survey/respond.c b/src/protocol/survey/respond.c index 3a4bf52d..5603b675 100644 --- a/src/protocol/survey/respond.c +++ b/src/protocol/survey/respond.c @@ -392,14 +392,13 @@ nni_resp_sock_rfilter(void *arg, nni_msg *msg) } -// This is the global protocol structure -- our linkage to the core. -// This should be the only global non-static symbol in this file. static nni_proto_pipe_ops nni_resp_pipe_ops = { .pipe_init = nni_resp_pipe_init, .pipe_fini = nni_resp_pipe_fini, .pipe_add = nni_resp_pipe_add, .pipe_rem = nni_resp_pipe_rem, - .pipe_worker = { nni_resp_pipe_send,nni_resp_pipe_recv }, + .pipe_worker = { nni_resp_pipe_send, + nni_resp_pipe_recv }, }; static nni_proto_sock_ops nni_resp_sock_ops = { diff --git a/tests/survey.c b/tests/survey.c index 3ead961d..7a5929ba 100644 --- a/tests/survey.c +++ b/tests/survey.c @@ -9,6 +9,7 @@ #include "convey.h" #include "nng.h" +#include "core/nng_impl.h" #include <string.h> @@ -44,8 +45,9 @@ Main({ }) Convey("Survey without responder times out", { - uint64_t expire = 1000; + uint64_t expire = 50000; nng_msg *msg; + int rv; So(nng_setopt(surv, NNG_OPT_SURVEYTIME, &expire, sizeof (expire)) == 0); So(nng_msg_alloc(&msg, 0) == 0); @@ -94,7 +96,7 @@ Main({ nng_close(resp); }) - expire = 40000; + expire = 50000; So(nng_setopt(surv, NNG_OPT_SURVEYTIME, &expire, sizeof (expire)) == 0); So(nng_listen(surv, addr, NULL, NNG_FLAG_SYNCH) == 0); @@ -129,7 +131,7 @@ Main({ So(nng_recvmsg(surv, &msg, 0) == NNG_ETIMEDOUT); Convey("And goes to non-survey state", { - rtimeo = 50000; + rtimeo = 200000; So(nng_setopt(surv, NNG_OPT_RCVTIMEO, &rtimeo, sizeof (rtimeo)) == 0); rv = nng_recvmsg(surv, &msg, 0); So(rv== NNG_ESTATE); |
