From: Lou Berger Date: Thu, 10 May 2018 12:47:11 +0000 (-0400) Subject: bgpd: block io thread reads once shutdown has started X-Git-Tag: frr-6.1-dev~450^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=97b4a0ec78f70a5f100e41a7222e121f4797a8fb;p=matthieu%2Ffrr.git bgpd: block io thread reads once shutdown has started Signed-off-by: Lou Berger --- 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)