lib: handle frr_pthread_init/fini in libfrr init

Make sure we are always cleaning init'ing and cleaning up pthread infra.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2019-08-09 18:03:01 +00:00
parent 54baf432f0
commit b9b4c0610a
3 changed files with 4 additions and 7 deletions

View File

@ -7931,8 +7931,6 @@ static void bgp_pthreads_init(void)
assert(!bgp_pth_io); assert(!bgp_pth_io);
assert(!bgp_pth_ka); assert(!bgp_pth_ka);
frr_pthread_init();
struct frr_pthread_attr io = { struct frr_pthread_attr io = {
.start = frr_pthread_attr_default.start, .start = frr_pthread_attr_default.start,
.stop = frr_pthread_attr_default.stop, .stop = frr_pthread_attr_default.stop,
@ -7958,7 +7956,6 @@ void bgp_pthreads_run(void)
void bgp_pthreads_finish(void) void bgp_pthreads_finish(void)
{ {
frr_pthread_stop_all(); frr_pthread_stop_all();
frr_pthread_finish();
} }
void bgp_init(unsigned short instance) void bgp_init(unsigned short instance)

View File

@ -42,6 +42,7 @@
#include "northbound_db.h" #include "northbound_db.h"
#include "debug.h" #include "debug.h"
#include "frrcu.h" #include "frrcu.h"
#include "frr_pthread.h"
DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm)) DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
DEFINE_KOOH(frr_early_fini, (), ()) DEFINE_KOOH(frr_early_fini, (), ())
@ -681,6 +682,8 @@ struct thread_master *frr_init(void)
memory_init(); memory_init();
log_filter_cmd_init(); log_filter_cmd_init();
frr_pthread_init();
log_ref_init(); log_ref_init();
log_ref_vty_init(); log_ref_vty_init();
lib_error_init(); lib_error_init();
@ -1076,6 +1079,7 @@ void frr_fini(void)
db_close(); db_close();
#endif #endif
log_ref_fini(); log_ref_fini();
frr_pthread_finish();
zprivs_terminate(di->privs); zprivs_terminate(di->privs);
/* signal_init -> nothing needed */ /* signal_init -> nothing needed */
thread_master_free(master); thread_master_free(master);

View File

@ -36,7 +36,6 @@
#include "vrf.h" #include "vrf.h"
#include "libfrr.h" #include "libfrr.h"
#include "routemap.h" #include "routemap.h"
#include "frr_pthread.h"
#include "zebra/zebra_router.h" #include "zebra/zebra_router.h"
#include "zebra/zebra_errors.h" #include "zebra/zebra_errors.h"
@ -375,9 +374,6 @@ int main(int argc, char **argv)
zrouter.master = frr_init(); zrouter.master = frr_init();
/* Initialize pthread library */
frr_pthread_init();
/* Zebra related initialize. */ /* Zebra related initialize. */
zebra_router_init(); zebra_router_init();
zserv_init(); zserv_init();