From 6ce80bdb2523ad82cef813f6d8a7e0d4daa8cfae Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Mon, 12 Nov 2007 14:55:01 +0000 Subject: + fixed bug #418 (changing address on an existing interface doesn't cause existing static routes to be revalidated) --- lib/workqueue.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lib/workqueue.c') diff --git a/lib/workqueue.c b/lib/workqueue.c index a0f48bc8..8880b9e2 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -66,6 +66,8 @@ work_queue_new (struct thread_master *m, const char *queue_name) new->name = XSTRDUP (MTYPE_WORK_QUEUE_NAME, queue_name); new->master = m; + SET_FLAG (new->flags, WQ_UNPLUGGED); + UNSET_FLAG (new->flags, WQ_AIM_HEAD); if ( (new->items = list_new ()) == NULL) { @@ -103,7 +105,7 @@ static inline int work_queue_schedule (struct work_queue *wq, unsigned int delay) { /* if appropriate, schedule work queue thread */ - if ( (wq->flags == WQ_UNPLUGGED) + if ( CHECK_FLAG (wq->flags, WQ_UNPLUGGED) && (wq->thread == NULL) && (listcount (wq->items) > 0) ) { @@ -129,7 +131,10 @@ work_queue_add (struct work_queue *wq, void *data) } item->data = data; - listnode_add (wq->items, item); + if (CHECK_FLAG (wq->flags, WQ_AIM_HEAD)) + listnode_add_after (wq->items, NULL, item); + else + listnode_add (wq->items, item); work_queue_schedule (wq, wq->spec.hold); @@ -186,7 +191,7 @@ DEFUN(show_work_queues, for (ALL_LIST_ELEMENTS_RO ((&work_queues), node, wq)) { vty_out (vty,"%c %8d %5d %8ld %7d %6d %6u %s%s", - (wq->flags == WQ_PLUGGED ? 'P' : ' '), + (CHECK_FLAG (wq->flags, WQ_UNPLUGGED) ? ' ' : 'P'), listcount (wq->items), wq->spec.hold, wq->runs, @@ -211,7 +216,7 @@ work_queue_plug (struct work_queue *wq) wq->thread = NULL; - wq->flags = WQ_PLUGGED; + UNSET_FLAG (wq->flags, WQ_UNPLUGGED); } /* unplug queue, schedule it again, if appropriate @@ -220,12 +225,21 @@ work_queue_plug (struct work_queue *wq) void work_queue_unplug (struct work_queue *wq) { - wq->flags = WQ_UNPLUGGED; + SET_FLAG (wq->flags, WQ_UNPLUGGED); /* if thread isnt already waiting, add one */ work_queue_schedule (wq, wq->spec.hold); } +void +work_queue_aim_head (struct work_queue *wq, const unsigned aim_head) +{ + if (aim_head) + SET_FLAG (wq->flags, WQ_AIM_HEAD); + else + UNSET_FLAG (wq->flags, WQ_AIM_HEAD); +} + /* timer thread to process a work queue * will reschedule itself if required, * otherwise work_queue_item_add -- cgit v1.2.1