From b9ec2b0c318e05ad5ea886eaec57fadfe07f6277 Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Sun, 17 Jan 2010 20:57:21 +0000 Subject: Further work-in-progress. modified: bgpd/bgp_connection.c completed pending queue modified: bgpd/bgp_engine.c TODOs for start/stop modified: bgpd/bgp_msg_write.c ) added send_update and send_eor modified: bgpd/bgp_msg_write.h ) modified: bgpd/bgp_open_state.c fixed free modified: bgpd/bgp_packet.c tidied up peer->work usage modified: bgpd/bgp_session.c ) completed various message handlers modified: bgpd/bgp_session.h ) modified: lib/mqueue.c ) added revoke modified: lib/mqueue.h ) --- lib/mqueue.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'lib/mqueue.c') diff --git a/lib/mqueue.c b/lib/mqueue.c index e1433245..f252586e 100644 --- a/lib/mqueue.c +++ b/lib/mqueue.c @@ -602,6 +602,59 @@ done: return mqb ; } ; +/*------------------------------------------------------------------------------ + * Revoke message(s) + * + * Revokes all messages, or only messages whose arg0 matches the given value. + * (If the given value is NULL revokes everything.) + * + * Revokes by calling mqb_dispatch_destroy(). + * + * During a revoke() operation more items may be enqueued, but no other mqueue + * operations may be performed. Enqueued items may promptly be revoked, except + * for priority items if the revoke operation has already moved past the last + * priority item. + */ +extern void +mqueue_revoke(mqueue_queue mq, void* arg0) +{ + mqueue_block mqb ; + mqueue_block prev ; + + qpt_mutex_lock(&mq->mutex) ; + + prev = NULL ; + while (1) + { + if (prev == NULL) + mqb = mq->head ; + else + mqb = prev->next ; + + if (mqb == NULL) + break ; + + if ((arg0 == NULL) || (arg0 == mqb->arg0)) + { + if (prev == NULL) + mq->head = mqb->next ; + else + prev->next = mqb->next ; + + if (mq->tail == mqb) + mq->tail = prev ; + + qpt_mutex_unlock(&mq->mutex) ; + mqb_dispatch_destroy(mqb) ; + qpt_mutex_lock(&mq->mutex) ; + } + else + prev = mqb ; + } ; + + qpt_mutex_unlock(&mq->mutex) ; +} ; + /*------------------------------------------------------------------------------ * No longer waiting for a signal -- does nothing if !qpthreads_enabled. * -- cgit v1.2.3