summaryrefslogtreecommitdiff
path: root/bgpd/bgp_keepalives.c
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2023-01-17 09:40:05 -0500
committerGitHub <noreply@github.com>2023-01-17 09:40:05 -0500
commit6664d745052afcb0f03d6e9ac01bbda44ad1810f (patch)
treea18e7e3b74bc6a9a9aaf0daf235baa12e45d21d3 /bgpd/bgp_keepalives.c
parent00d7261e203a6f9426f7ced1c1b940fc9191fe2b (diff)
parent8c9d306c8d2adf34d11bb1566fda6f0a8bfe7990 (diff)
Merge pull request #12641 from samanvithab/bgpd_crash
bgpd: Fix crash during shutdown due to race condition
Diffstat (limited to 'bgpd/bgp_keepalives.c')
-rw-r--r--bgpd/bgp_keepalives.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c
index 0e83157ecd..fb1237c022 100644
--- a/bgpd/bgp_keepalives.c
+++ b/bgpd/bgp_keepalives.c
@@ -273,8 +273,9 @@ void bgp_keepalives_on(struct peer *peer)
peer_lock(peer);
}
SET_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON);
+ /* Force the keepalive thread to wake up */
+ pthread_cond_signal(peerhash_cond);
}
- bgp_keepalives_wake();
}
void bgp_keepalives_off(struct peer *peer)
@@ -304,19 +305,15 @@ void bgp_keepalives_off(struct peer *peer)
}
}
-void bgp_keepalives_wake(void)
-{
- frr_with_mutex (peerhash_mtx) {
- pthread_cond_signal(peerhash_cond);
- }
-}
-
int bgp_keepalives_stop(struct frr_pthread *fpt, void **result)
{
assert(fpt->running);
- atomic_store_explicit(&fpt->running, false, memory_order_relaxed);
- bgp_keepalives_wake();
+ frr_with_mutex (peerhash_mtx) {
+ atomic_store_explicit(&fpt->running, false,
+ memory_order_relaxed);
+ pthread_cond_signal(peerhash_cond);
+ }
pthread_join(fpt->thread, result);
return 0;