From 51d8e2457d73c709bfa4f706793696b3ce704ff9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 26 Oct 2018 10:39:28 -0500 Subject: [PATCH] osd: take heartbeat_lock before checking for session When we open a connection, there is a short window before we attach the session. If a fault happens quickly, we won't get the reset, and will persistently fail to send osd pings. Move the lock up to avoid this. Note that we should rarely really see connections without sessions here anyway (except when this specific race happens), so this should have no negative impact (by taking the lock when we weren't before). Fixes: http://tracker.ceph.com/issues/36602 Signed-off-by: Sage Weil --- src/osd/OSD.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 0c07b1b2945b1..b7168be921310 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4957,9 +4957,9 @@ void OSD::heartbeat() bool OSD::heartbeat_reset(Connection *con) { + std::lock_guard l(heartbeat_lock); auto s = con->get_priv(); if (s) { - heartbeat_lock.Lock(); if (is_stopping()) { heartbeat_lock.Unlock(); return true; @@ -4996,7 +4996,6 @@ bool OSD::heartbeat_reset(Connection *con) } else { dout(10) << "heartbeat_reset closing (old) failed hb con " << con << dendl; } - heartbeat_lock.Unlock(); } return true; } -- 2.39.5