summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2018-05-10 08:47:11 -0400
committerLou Berger <lberger@labn.net>2018-05-10 08:47:11 -0400
commit97b4a0ec78f70a5f100e41a7222e121f4797a8fb (patch)
tree997cad24a7d615bc5743a046d2259d7e951943fe
parent1c96f2fb9631415ec44046c915520f489a93ebc4 (diff)
bgpd: block io thread reads once shutdown has started
Signed-off-by: Lou Berger <lberger@labn.net>
-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 a331fad5d4..58d9fb24e0 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7559,6 +7559,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 470fd10850..f460b0fa98 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)