From ebefc71efae64b72ce75efe10c447344edf7242f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 11 Dec 2018 21:25:12 -0800 Subject: fixes #812 message queue put_error unused --- src/core/msgqueue.c | 56 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) (limited to 'src/core/msgqueue.c') diff --git a/src/core/msgqueue.c b/src/core/msgqueue.c index 3419f029..773fb9aa 100644 --- a/src/core/msgqueue.c +++ b/src/core/msgqueue.c @@ -22,7 +22,6 @@ struct nni_msgq { int mq_len; int mq_get; int mq_put; - int mq_puterr; int mq_geterr; bool mq_closed; nni_msg **mq_msgs; @@ -81,7 +80,6 @@ nni_msgq_init(nni_msgq **mqp, unsigned cap) mq->mq_get = 0; mq->mq_put = 0; mq->mq_closed = 0; - mq->mq_puterr = 0; mq->mq_geterr = 0; *mqp = mq; @@ -146,50 +144,6 @@ nni_msgq_set_get_error(nni_msgq *mq, int error) nni_mtx_unlock(&mq->mq_lock); } -void -nni_msgq_set_put_error(nni_msgq *mq, int error) -{ - // Let all pending blockers know we are closing the queue. - nni_mtx_lock(&mq->mq_lock); - if (mq->mq_closed) { - // If we were closed, then this error trumps all others. - error = NNG_ECLOSED; - } - if (error != 0) { - nni_aio *aio; - while ((aio = nni_list_first(&mq->mq_aio_putq)) != NULL) { - nni_aio_list_remove(aio); - nni_aio_finish_error(aio, error); - } - } - mq->mq_puterr = error; - nni_msgq_run_notify(mq); - nni_mtx_unlock(&mq->mq_lock); -} - -void -nni_msgq_set_error(nni_msgq *mq, int error) -{ - // Let all pending blockers know we are closing the queue. - nni_mtx_lock(&mq->mq_lock); - if (mq->mq_closed) { - // If we were closed, then this error trumps all others. - error = NNG_ECLOSED; - } - if (error != 0) { - nni_aio *aio; - while (((aio = nni_list_first(&mq->mq_aio_getq)) != NULL) || - ((aio = nni_list_first(&mq->mq_aio_putq)) != NULL)) { - nni_aio_list_remove(aio); - nni_aio_finish_error(aio, error); - } - } - mq->mq_puterr = error; - mq->mq_geterr = error; - nni_msgq_run_notify(mq); - nni_mtx_unlock(&mq->mq_lock); -} - void nni_msgq_flush(nni_msgq *mq) { @@ -375,20 +329,14 @@ nni_msgq_aio_put(nni_msgq *mq, nni_aio *aio) return; } nni_mtx_lock(&mq->mq_lock); - if (mq->mq_puterr) { - nni_atomic_inc64(&mq->mq_put_errs, 1); - nni_aio_finish_error(aio, mq->mq_puterr); - nni_mtx_unlock(&mq->mq_lock); - return; - } // If this is an instantaneous poll operation, and the queue has // no room, nobody is waiting to receive, then report NNG_ETIMEDOUT. rv = nni_aio_schedule(aio, nni_msgq_cancel, mq); if ((rv != 0) && (mq->mq_len >= mq->mq_cap) && (nni_list_empty(&mq->mq_aio_getq))) { - nni_atomic_inc64(&mq->mq_put_errs, 1); nni_mtx_unlock(&mq->mq_lock); + nni_atomic_inc64(&mq->mq_put_errs, 1); nni_aio_finish_error(aio, rv); return; } @@ -492,7 +440,7 @@ nni_msgq_close(nni_msgq *mq) nni_mtx_lock(&mq->mq_lock); mq->mq_closed = true; - mq->mq_puterr = mq->mq_geterr = NNG_ECLOSED; + mq->mq_geterr = NNG_ECLOSED; // Free the messages orphaned in the queue. while (mq->mq_len > 0) { -- cgit v1.2.3-70-g09d2