From 774914f4223532256051bd6dd61cac20e8f9649f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Oct 2015 08:50:39 -0400 Subject: bgpd: fix using of two pointers for struct thread_master * bgp is using both bm->master and master pointers interchangebly for thread manipulation. Since they are the same thing consolidate to one pointer. Signed-off-by: Donald Sharp --- bgpd/bgp_damp.c | 4 ++-- bgpd/bgp_dump.c | 4 ++-- bgpd/bgp_fsm.h | 10 +++++----- bgpd/bgp_main.c | 16 +++++----------- bgpd/bgp_network.c | 4 ++-- bgpd/bgp_nexthop.c | 16 ++++++++-------- bgpd/bgpd.c | 4 ++-- bgpd/bgpd.h | 2 -- 8 files changed, 26 insertions(+), 34 deletions(-) (limited to 'bgpd') diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 05c30ff0..359fce36 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -115,7 +115,7 @@ bgp_reuse_timer (struct thread *t) damp->t_reuse = NULL; damp->t_reuse = - thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE); + thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE); t_now = bgp_clock (); @@ -447,7 +447,7 @@ bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t safi, time_t half, /* Register reuse timer. */ if (! damp->t_reuse) damp->t_reuse = - thread_add_timer (master, bgp_reuse_timer, NULL, DELTA_REUSE); + thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE); return 0; } diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index a3c9526f..3d88dee4 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -156,13 +156,13 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval) secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour; interval = interval - secs_into_day % interval; /* always > 0 */ } - bgp_dump->t_interval = thread_add_timer (master, bgp_dump_interval_func, + bgp_dump->t_interval = thread_add_timer (bm->master, bgp_dump_interval_func, bgp_dump, interval); } else { /* One-off dump: execute immediately, don't affect any scheduled dumps */ - bgp_dump->t_interval = thread_add_event (master, bgp_dump_interval_func, + bgp_dump->t_interval = thread_add_event (bm->master, bgp_dump_interval_func, bgp_dump, 0); } diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index a749f8ea..752d6e2b 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -26,7 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define BGP_READ_ON(T,F,V) \ do { \ if (!(T) && (peer->status != Deleted)) \ - THREAD_READ_ON(master,T,F,peer,V); \ + THREAD_READ_ON(bm->master,T,F,peer,V); \ } while (0) #define BGP_READ_OFF(T) \ @@ -38,7 +38,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define BGP_WRITE_ON(T,F,V) \ do { \ if (!(T) && (peer->status != Deleted)) \ - THREAD_WRITE_ON(master,(T),(F),peer,(V)); \ + THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \ } while (0) #define BGP_WRITE_OFF(T) \ @@ -50,7 +50,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define BGP_TIMER_ON(T,F,V) \ do { \ if (!(T) && (peer->status != Deleted)) \ - THREAD_TIMER_ON(master,(T),(F),peer,(V)); \ + THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \ } while (0) #define BGP_TIMER_OFF(T) \ @@ -62,13 +62,13 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define BGP_EVENT_ADD(P,E) \ do { \ if ((P)->status != Deleted) \ - thread_add_event (master, bgp_event, (P), (E)); \ + thread_add_event (bm->master, bgp_event, (P), (E)); \ } while (0) #define BGP_EVENT_FLUSH(P) \ do { \ assert (peer); \ - thread_cancel_event (master, (P)); \ + thread_cancel_event (bm->master, (P)); \ } while (0) /* Prototypes. */ diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 7c2988cd..cacff234 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -105,9 +105,6 @@ char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG; /* Route retain mode flag. */ static int retain_mode = 0; -/* Master of threads. */ -struct thread_master *master; - /* Manually specified configuration file name. */ char *config_file = NULL; @@ -302,8 +299,8 @@ bgp_exit (int status) stream_free (bgp_nexthop_buf); /* reverse bgp_master_init */ - if (master) - thread_master_free (master); + if (bm->master) + thread_master_free (bm->master); if (zlog_default) closezlog (zlog_default); @@ -416,15 +413,12 @@ main (int argc, char **argv) } } - /* Make thread master. */ - master = bm->master; - /* Initializations. */ srandom (time (NULL)); - signal_init (master, array_size(bgp_signals), bgp_signals); + signal_init (bm->master, array_size(bgp_signals), bgp_signals); zprivs_init (&bgpd_privs); cmd_init (1); - vty_init (master); + vty_init (bm->master); memory_init (); vrf_init (); @@ -459,7 +453,7 @@ main (int argc, char **argv) bm->port); /* Start finite state machine, here we go! */ - while (thread_fetch (master, &thread)) + while (thread_fetch (bm->master, &thread)) thread_call (&thread); /* Not reached. */ diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 7059e8ae..8621854b 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -207,7 +207,7 @@ bgp_accept (struct thread *thread) zlog_err ("accept_sock is nevative value %d", accept_sock); return -1; } - listener->thread = thread_add_read (master, bgp_accept, listener, accept_sock); + listener->thread = thread_add_read (bm->master, bgp_accept, listener, accept_sock); /* Accept client connection. */ bgp_sock = sockunion_accept (accept_sock, &su); @@ -480,7 +480,7 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen) listener = XMALLOC (MTYPE_BGP_LISTENER, sizeof(*listener)); listener->fd = sock; memcpy(&listener->su, sa, salen); - listener->thread = thread_add_read (master, bgp_accept, listener, sock); + listener->thread = thread_add_read (bm->master, bgp_accept, listener, sock); listnode_add (bm->listen_sockets, listener); return 0; diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 183a28b1..bb658afb 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -529,7 +529,7 @@ static int bgp_scan_timer (struct thread *t) { bgp_scan_thread = - thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval); + thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval); if (BGP_DEBUG (events, EVENTS)) zlog_debug ("Performing BGP general scanning"); @@ -1103,7 +1103,7 @@ bgp_import (struct thread *t) safi_t safi; bgp_import_thread = - thread_add_timer (master, bgp_import, NULL, bgp_import_interval); + thread_add_timer (bm->master, bgp_import, NULL, bgp_import_interval); if (BGP_DEBUG (events, EVENTS)) zlog_debug ("Import timer expired."); @@ -1230,7 +1230,7 @@ DEFUN (bgp_scan_time, { thread_cancel (bgp_scan_thread); bgp_scan_thread = - thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval); + thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval); } return CMD_SUCCESS; @@ -1249,7 +1249,7 @@ DEFUN (no_bgp_scan_time, { thread_cancel (bgp_scan_thread); bgp_scan_thread = - thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval); + thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval); } return CMD_SUCCESS; @@ -1400,9 +1400,9 @@ bgp_config_write_scan_time (struct vty *vty) void bgp_scan_init (void) { - zlookup = zclient_new (master); + zlookup = zclient_new (bm->master); zlookup->sock = -1; - zlookup->t_connect = thread_add_event (master, zlookup_connect, zlookup, 0); + zlookup->t_connect = thread_add_event (bm->master, zlookup_connect, zlookup, 0); bgp_scan_interval = BGP_SCAN_INTERVAL_DEFAULT; bgp_import_interval = BGP_IMPORT_INTERVAL_DEFAULT; @@ -1421,10 +1421,10 @@ bgp_scan_init (void) #endif /* HAVE_IPV6 */ /* Make BGP scan thread. */ - bgp_scan_thread = thread_add_timer (master, bgp_scan_timer, + bgp_scan_thread = thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval); /* Make BGP import there. */ - bgp_import_thread = thread_add_timer (master, bgp_import, NULL, 0); + bgp_import_thread = thread_add_timer (bm->master, bgp_import, NULL, 0); install_element (BGP_NODE, &bgp_scan_time_cmd); install_element (BGP_NODE, &no_bgp_scan_time_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index af8bdb45..3fdd9ff6 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1978,7 +1978,7 @@ bgp_create (as_t *as, const char *name) if (name) bgp->name = strdup (name); - THREAD_TIMER_ON (master, bgp->t_startup, bgp_startup_timer_expire, + THREAD_TIMER_ON (bm->master, bgp->t_startup, bgp_startup_timer_expire, bgp, bgp->restart_time); return bgp; @@ -5421,7 +5421,7 @@ bgp_init (void) bgp_vty_init (); /* Init zebra. */ - bgp_zebra_init (master); + bgp_zebra_init (bm->master); /* BGP inits. */ bgp_attr_init (); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 7ae0acb3..95c16de0 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -834,8 +834,6 @@ enum bgp_clear_type extern struct bgp_master *bm; -extern struct thread_master *master; - /* Prototypes. */ extern void bgp_terminate (void); extern void bgp_reset (void); -- cgit v1.2.3