bgpd: block io thread reads once shutdown has started

Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
Lou Berger 2018-05-10 08:47:11 -04:00
parent 1c96f2fb96
commit 97b4a0ec78
4 changed files with 5 additions and 1 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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)