summaryrefslogtreecommitdiffstats
path: root/lib/mqueue.c
diff options
context:
space:
mode:
authorpaulo <paul@bayleaf.org.uk>2010-01-25 16:18:53 +0000
committerpaulo <paul@bayleaf.org.uk>2010-01-25 16:18:53 +0000
commit649f8b0429dc1b25d65c34ee461e448d8f56f410 (patch)
tree9c8185dc2e1319a425eeb1ac75b10f27c1d60674 /lib/mqueue.c
parentc21f7fd3e23791cb6ea8a3b0b968af8892c75931 (diff)
downloadquagga-649f8b0429dc1b25d65c34ee461e448d8f56f410.tar.bz2
quagga-649f8b0429dc1b25d65c34ee461e448d8f56f410.tar.xz
Fixed problems in mqueue keeping tail pointers correct. Implemented
program terminate code that waits for all sissions to become disabled before terminating pthreads and running exit code.
Diffstat (limited to 'lib/mqueue.c')
-rw-r--r--lib/mqueue.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/mqueue.c b/lib/mqueue.c
index f252586e..3031891e 100644
--- a/lib/mqueue.c
+++ b/lib/mqueue.c
@@ -434,11 +434,15 @@ mqueue_enqueue(mqueue_queue mq, mqueue_block mqb, int priority)
{
mqb->next = mq->head ;
mq->head = mqb ;
+ /* mq non-empty, enchain at head, therefore tail unaffected */
}
else
{
mqb->next = after->next ;
after->next = mqb ;
+ /* if only have priority messages then fix tail */
+ if (mq->tail == after)
+ mq->tail = mqb;
}
mq->tail_priority = mqb ;
}
@@ -593,6 +597,10 @@ mqueue_dequeue(mqueue_queue mq, int wait, void* arg)
/* Have something to pull off the queue */
mq->head = mqb->next ;
+
+ /* fix tails if at tail */
+ if (mqb == mq->tail)
+ mq->tail = NULL ;
if (mqb == mq->tail_priority)
mq->tail_priority = NULL ;
@@ -644,6 +652,9 @@ mqueue_revoke(mqueue_queue mq, void* arg0)
if (mq->tail == mqb)
mq->tail = prev ;
+ if (mqb == mq->tail_priority)
+ mq->tail_priority = prev ;
+
qpt_mutex_unlock(&mq->mutex) ;
mqb_dispatch_destroy(mqb) ;
qpt_mutex_lock(&mq->mutex) ;