summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2018-05-12 06:27:00 -0400
committerGitHub <noreply@github.com>2018-05-12 06:27:00 -0400
commit2d6d27bcf1b64a2f3271f985c10c2b9bf5a120f6 (patch)
tree0880c4891e2fbb9a032239d360d9bf32692dea37
parent16c3f0882344eda452650fdfb07f17005c1f634f (diff)
parent97b4a0ec78f70a5f100e41a7222e121f4797a8fb (diff)
Merge pull request #2196 from LabNConsulting/working/master/bgpd-shutdown-race
BGP: Preclude race condition between listener thread and core during shutdown
-rw-r--r--bgpd/bgp_io.c2
-rw-r--r--bgpd/bgp_main.c2
-rw-r--r--bgpd/bgpd.c1
-rw-r--r--bgpd/bgpd.h1
4 files changed, 5 insertions, 1 deletions
diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c
index 3882ff8b56..69c92e829c 100644
--- a/bgpd/bgp_io.c
+++ b/bgpd/bgp_io.c
@@ -179,7 +179,7 @@ static int bgp_process_reads(struct thread *thread)
peer = THREAD_ARG(thread);
- if (peer->fd < 0)
+ if (peer->fd < 0 || bm->terminating)
return -1;
struct frr_pthread *fpt = frr_pthread_get(PTHREAD_IO);
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 5158717b5d..004bdd90a2 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -143,6 +143,8 @@ void sighup(void)
__attribute__((__noreturn__)) void sigint(void)
{
zlog_notice("Terminating on signal");
+ assert(bm->terminating == false);
+ bm->terminating = true; /* global flag that shutting down */
if (!retain_mode)
bgp_terminate();
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index b8ac11a47b..71707b6afa 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7619,6 +7619,7 @@ void bgp_master_init(struct thread_master *master)
bm->start_time = bgp_clock();
bm->t_rmap_update = NULL;
bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
+ bm->terminating = false;
bgp_process_queue_init();
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index d9ce77a55a..1ad6a5c9c8 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -144,6 +144,7 @@ struct bgp_master {
/* dynamic mpls label allocation pool */
struct labelpool labelpool;
+ bool terminating; /* global flag that sigint terminate seen */
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(bgp_master)