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 /bgpd/bgp_main.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 'bgpd/bgp_main.c')
-rw-r--r-- | bgpd/bgp_main.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 69767a9f..cb2eef29 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -207,7 +207,19 @@ sigint (void) if (! retain_mode) bgp_terminate (); - bgp_exit (0); + if (qpthreads_enabled) + { + /* ask all threads to terminate */ + if (bgp_nexus) + qpn_terminate(bgp_nexus); + + if (cli_nexus) + qpn_terminate(cli_nexus); + } + else + { + bgp_exit (0); + } } /* SIGUSR1 handler. */ @@ -319,13 +331,8 @@ bgp_exit (int status) if (CONF_BGP_DEBUG (normal, NORMAL)) log_memstats_stderr ("bgpd"); - if (bgp_nexus) - bgp_nexus->terminate = 1; - - if (cli_nexus) - cli_nexus->terminate = 1; /* waste of time, its the main thread */ - - /* TODO: join threads ? */ + bgp_nexus = qpn_free(bgp_nexus); + cli_nexus = qpn_free(cli_nexus); qexit (status); } @@ -477,7 +484,6 @@ main (int argc, char **argv) cli_nexus = qpn_init_main(cli_nexus); /* main thread */ bgp_nexus = qpn_init_bgp(bgp_nexus); - zprivs_init_r (); vty_init_r(cli_nexus, bgp_nexus); } @@ -493,8 +499,16 @@ main (int argc, char **argv) /* Launch finite state machines */ if (qpthreads_enabled) { + void * thread_result = NULL; + int result = 0; + qpn_exec(bgp_nexus); qpn_exec(cli_nexus); /* must be last to start - on main thread */ + + /* terminating, wait for all threads to finish */ + /* TODO need qpt_ version */ + result = pthread_join(bgp_nexus->thread_id, &thread_result); + bgp_exit(result); } else { |