diff options
author | paulo <paul@bayleaf.org.uk> | 2009-12-17 15:41:58 +0000 |
---|---|---|
committer | paulo <paul@bayleaf.org.uk> | 2009-12-17 15:41:58 +0000 |
commit | 57c08de786262cfb59cbc691ac18712d0ac1e9e3 (patch) | |
tree | b52688512b6703112245bcfd6ee63421abdc0c20 /lib/qpnexus.c | |
parent | 550bd24b6140cbf36e1bbc175d8719b1521a716e (diff) | |
download | quagga-57c08de786262cfb59cbc691ac18712d0ac1e9e3.tar.bz2 quagga-57c08de786262cfb59cbc691ac18712d0ac1e9e3.tar.xz |
Fix shutdown. Move cpu stats command to cli thread.
Diffstat (limited to 'lib/qpnexus.c')
-rw-r--r-- | lib/qpnexus.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/qpnexus.c b/lib/qpnexus.c index 5a5c5417..fa500e36 100644 --- a/lib/qpnexus.c +++ b/lib/qpnexus.c @@ -84,13 +84,18 @@ qpn_init_bgp(qpn_nexus qpn) return qpn; } -/* free timers, selection, message queue and nexus */ -static void +/* free timers, selection, message queue and nexus + * return NULL + */ +qpn_nexus qpn_free(qpn_nexus qpn) { qps_file qf; qtimer qtr; + if (qpn == NULL) + return NULL; + /* timers and the pile */ if (qpn->pile != NULL) { @@ -112,6 +117,8 @@ qpn_free(qpn_nexus qpn) /* TODO: free qtn->queue */ XFREE(MTYPE_QPN_NEXUS, qpn) ; + + return NULL; } /* If not main thread create new qpthread. @@ -127,7 +134,7 @@ qpn_exec(qpn_nexus qpn) else { /* create a qpthread and run the state machine in it */ - qpn->thread_id = qpt_thread_create(qpn->start, qpn, NULL) ; + qpt_thread_create(qpn->start, qpn, NULL) ; } } @@ -173,8 +180,6 @@ qpn_start_main(void* arg) } } - qpn_free(qpn); - return NULL; } @@ -224,7 +229,14 @@ qpn_start_bgp(void* arg) mqueue_done_waiting(qpn->queue, qpn->mts); } - qpn_free(qpn); - return NULL; } + +/* Ask the thread to terminate itself quickly and cleanly */ +void +qpn_terminate(qpn_nexus qpn) +{ + qpn->terminate = 1; + /* wake up any pselect */ + qpt_thread_signal(qpn->thread_id, SIGMQUEUE); +} |