diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-19 01:12:11 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-19 01:12:11 +0000 |
commit | 7fc51586dd130786b2cde348cf64967de12cf4f3 (patch) | |
tree | 8f59c922b727c41b9e4d74aae1df68971773c58a /lib/qpnexus.c | |
parent | edc82cd294e7c4cfca309e08abede282456ca376 (diff) | |
parent | e0f9836737c9e91b8fa4c72b45d1fdc286e2d811 (diff) | |
download | quagga-7fc51586dd130786b2cde348cf64967de12cf4f3.tar.bz2 quagga-7fc51586dd130786b2cde348cf64967de12cf4f3.tar.xz |
Merge branch 'bgp_engine' of /git/quagga.euro-ix into bgp_engine
Diffstat (limited to 'lib/qpnexus.c')
-rw-r--r-- | lib/qpnexus.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/qpnexus.c b/lib/qpnexus.c index 98bd767c..270142be 100644 --- a/lib/qpnexus.c +++ b/lib/qpnexus.c @@ -121,7 +121,7 @@ qpn_exec(qpn_nexus qpn) * * 1) Main thread only -- signals. * - * 2) Pending work -- local queue. + * 2) Pending work -- event hooks. * * 3) messages coming from other pthreads -- mqueue_queue. * @@ -145,7 +145,8 @@ qpn_start(void* arg) mqueue_block mqb; int actions; qtime_mono_t now; - struct thread thread; + qtime_mono_t max_wait; + int i; /* now in our thread, complete initialisation */ qpn_in_thread_init(qpn); @@ -157,6 +158,21 @@ qpn_start(void* arg) if (qpn->main_thread) quagga_sigevent_process (); + /* max time to wait in pselect */ + now = qt_get_monotonic(); + max_wait = now + QTIME(MAX_PSELECT_TIMOUT); + + /* event hooks, if any */ + for (i = 0; i < NUM_EVENT_HOOK; ++i) + { + if (qpn->event_hook[i] != NULL) + { + qtime_mono_t event_wait = qpn->event_hook[i](); + if (event_wait > 0 && event_wait < max_wait) + max_wait = event_wait; + } + } + /* drain the message queue, will be in waiting for signal state * when it's empty */ for (;;) @@ -169,9 +185,8 @@ qpn_start(void* arg) } /* block for some input, output, signal or timeout */ - now = qt_get_monotonic(); actions = qps_pselect(qpn->selection, - qtimer_pile_top_time(qpn->pile, now + QTIME(MAX_PSELECT_TIMOUT)) ); + qtimer_pile_top_time(qpn->pile, max_wait)); /* process I/O actions */ while (actions) @@ -184,15 +199,6 @@ qpn_start(void* arg) while (qtimer_pile_dispatch_next(qpn->pile, now)) { } - - /* legacy threads */ - /* TODO: legacy threads must not pselect. How is the pselect above - * to know when to timeout for legacy timers? */ - if (qpn->master != NULL) - { - if (thread_fetch (qpn->master, &thread)) - thread_call (&thread); - } } /* last bit of code to run in this thread */ |