]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: fix m_stop_requested leading to a race
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Fri, 21 Mar 2025 08:59:45 +0000 (14:29 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:36 +0000 (21:26 +0530)
* if m_stop_requested is set then is_replay_interrupted return true.
* also shut_down should set m_stop_requested to false, it is instead
  setting it to true this will lead to race and a possible crash accessing GR
  b/w shut_down() and notify_group_listener_stop()

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/tools/rbd_mirror/group_replayer/Replayer.cc

index 57ab0d8b9025934199d43489d0f166f690501806..c1c59c34e56913cea860ffa481751a4c37024177 100644 (file)
@@ -78,7 +78,7 @@ bool Replayer<I>::is_replay_interrupted() {
 template <typename I>
 bool Replayer<I>::is_replay_interrupted(std::unique_lock<ceph::mutex>* locker) {
 
-  if (m_state == STATE_COMPLETE) {
+  if (m_state == STATE_COMPLETE || m_stop_requested) {
     locker->unlock();
     return true;
   }
@@ -1220,7 +1220,7 @@ void Replayer<I>::shut_down(Context* on_finish) {
 
   {
     std::unique_lock locker{m_lock};
-    m_stop_requested = true;
+    m_stop_requested = false;
     ceph_assert(m_on_shutdown == nullptr);
     std::swap(m_on_shutdown, on_finish);