From 848f8f62d7c6d6ea061dd0513a6bffc1ef358ff3 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 9 Jan 2017 13:01:22 -0800 Subject: Add survey test (and fix survey pattern). As part of this, we've added a way to unblock callers in a message queue with an error, even without a signal channel. This was necessary to interrupt blockers upon survey timeout. They will get NNG_ETIMEDOUT, but afterwards callers get NNG_ESTATE. --- src/core/msgqueue.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/core/msgqueue.h') diff --git a/src/core/msgqueue.h b/src/core/msgqueue.h index 09d7fa0c..450c55a4 100644 --- a/src/core/msgqueue.h +++ b/src/core/msgqueue.h @@ -87,6 +87,24 @@ extern int nni_msgq_get_sig(nni_msgq *, nni_msg **, nni_signal *); // It modifies the turnstile's value under the lock to a non-zero value. extern void nni_msgq_signal(nni_msgq *, nni_signal *); +// nni_msgq_set_error sets an error condition on the message queue, +// which causes all current and future readers/writes to return the +// given error condition (if non-zero). Threads waiting to put or get +// are woken as well, if non-zero. If zero, then any present error +// condition is cleared, and waiters are not woken (there shouldn't be +// any waiters unless it was already zero.) +extern void nni_msgq_set_error(nni_msgq *, int); + +// nni_msgq_set_put_error sets an error condition on the put side of the +// message queue, and for that side behaves like nni_msgq_set_error. +// Readers (nni_msgq_get*) are unaffected. +extern void nni_msgq_set_put_error(nni_msgq *, int); + +// nni_msgq_set_get_error sets an error condition on the get side of the +// message queue, and for that side behaves like nni_msgq_set_error. +// Readers (nni_msgq_put*) are unaffected. +extern void nni_msgq_set_get_error(nni_msgq *, int); + // nni_msgq_close closes the queue. After this all operates on the // message queue will return NNG_ECLOSED. Messages inside the queue // are freed. Unlike closing a go channel, this operation is idempotent. -- cgit v1.2.3-70-g09d2