diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/memtypes.c | 1 | ||||
-rw-r--r-- | lib/mqueue.c | 6 | ||||
-rw-r--r-- | lib/mqueue.h | 9 | ||||
-rw-r--r-- | lib/qpnexus.c | 34 |
4 files changed, 26 insertions, 24 deletions
diff --git a/lib/memtypes.c b/lib/memtypes.c index d0cb1eee..98b53209 100644 --- a/lib/memtypes.c +++ b/lib/memtypes.c @@ -143,6 +143,7 @@ struct memory_list memory_list_bgp[] = { MTYPE_BGP_NODE, "BGP node" }, { MTYPE_BGP_ROUTE, "BGP route" }, { MTYPE_BGP_ROUTE_EXTRA, "BGP ancillary route info" }, + { MTYPE_BGP_CONN, "BGP connected" }, { MTYPE_BGP_STATIC, "BGP static" }, { MTYPE_BGP_ADVERTISE_ATTR, "BGP adv attr" }, { MTYPE_BGP_ADVERTISE, "BGP adv" }, diff --git a/lib/mqueue.c b/lib/mqueue.c index 90e1616c..8fa9fbd5 100644 --- a/lib/mqueue.c +++ b/lib/mqueue.c @@ -509,8 +509,8 @@ static void mqueue_dequeue_signal(mqueue_queue mq, mqueue_thread_signal mtsig) ; /*------------------------------------------------------------------------------ * Enqueue message. * - * If priority != 0, will enqueue after any previously enqueued priority - * messages. + * If priority, will enqueue after any previously enqueued priority + * messages. (See enum: mqb_priority and mqb_ordinary.) * * If there are any waiters, then we kick one or all of them. * @@ -533,7 +533,7 @@ static void mqueue_dequeue_signal(mqueue_queue mq, mqueue_thread_signal mtsig) ; * never be any waiters... so no kicking is ever done. */ extern void -mqueue_enqueue(mqueue_queue mq, mqueue_block mqb, int priority) +mqueue_enqueue(mqueue_queue mq, mqueue_block mqb, enum mqb_rank priority) { if (mq == NULL) return mqb_dispatch_destroy(mqb) ; diff --git a/lib/mqueue.h b/lib/mqueue.h index f22ea022..a28b6606 100644 --- a/lib/mqueue.h +++ b/lib/mqueue.h @@ -23,6 +23,7 @@ #define _ZEBRA_MQUEUE_H #include <stddef.h> +#include <stdbool.h> #include "qpthreads.h" #include "qtime.h" @@ -243,8 +244,14 @@ mqb_re_init(mqueue_block mqb, mqueue_action action, void* arg0) ; extern void mqb_free(mqueue_block mqb) ; +enum mqb_rank +{ + mqb_priority = true, + mqb_ordinary = false +} ; + extern void -mqueue_enqueue(mqueue_queue mq, mqueue_block mqb, int priority) ; +mqueue_enqueue(mqueue_queue mq, mqueue_block mqb, enum mqb_rank priority) ; extern mqueue_block mqueue_dequeue(mqueue_queue mq, int wait, void* arg) ; diff --git a/lib/qpnexus.c b/lib/qpnexus.c index e568e7d8..59dcc535 100644 --- a/lib/qpnexus.c +++ b/lib/qpnexus.c @@ -191,29 +191,23 @@ qpn_start(void* arg) done = 1 ; while (!qpn->terminate) { - wait = (done == 0) ; /* may wait this time only if nothing - found to do on the last pass */ - - /* Signals are highest priority -- only execute for main thread - * - * Restarts "done" for this pass. - */ + /* Signals are highest priority -- only execute for main thread */ if (qpn->main_thread) - done = quagga_sigevent_process() ; - else - done = 0 ; + done |= quagga_sigevent_process() ; /* Foreground hooks, if any. */ for (i = 0; i < qpn->foreground.count ;) done |= ((qpn_hook_function*)(qpn->foreground.hooks[i++]))() ; - /* drain the message queue, will be in waiting for signal state - * when it's empty */ - - if (done != 0) - wait = 0 ; /* turn off wait if found something */ - - while (1) + /* take stuff from the message queue + * + * If nothing done the last time around the loop then may wait this + * time if the queue is empty first time through. + */ + wait = (done == 0) ; /* may wait this time only if nothing + found to do on the last pass */ + done = 0 ; + do { mqb = mqueue_dequeue(qpn->queue, wait, qpn->mts) ; if (mqb == NULL) @@ -221,9 +215,9 @@ qpn_start(void* arg) mqb_dispatch(mqb, mqb_action); - done = 1 ; /* done something */ - wait = 0 ; /* turn off wait */ - } ; + ++done ; /* done another */ + wait = 0 ; /* done something, so turn off wait */ + } while (done < 200) ; /* block for some input, output, signal or timeout * |