]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: clear init/shutdown context before completion
authorJason Dillaman <dillaman@redhat.com>
Sun, 22 Dec 2019 22:16:17 +0000 (17:16 -0500)
committerJason Dillaman <dillaman@redhat.com>
Sun, 22 Dec 2019 22:16:17 +0000 (17:16 -0500)
This fixes a potential issue where the init fails and shut down
is called with the original init context still set.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/image_replayer/journal/Replayer.cc

index 59c2ab239b8edda732a20f9d0e45f7bd7807a164..be7ec3061bd5027776a73dca0866836d7e026911 100644 (file)
@@ -596,8 +596,13 @@ void Replayer<I>::handle_wait_for_in_flight_ops(int r) {
   ReplayStatusFormatter<I>::destroy(m_replay_status_formatter);
   m_replay_status_formatter = nullptr;
 
-  ceph_assert(m_on_init_shutdown != nullptr);
-  m_on_init_shutdown->complete(m_error_code);
+  Context* on_init_shutdown = nullptr;
+  {
+    std::unique_lock locker{m_lock};
+    ceph_assert(m_on_init_shutdown != nullptr);
+    std::swap(m_on_init_shutdown, on_init_shutdown);
+  }
+  on_init_shutdown->complete(m_error_code);
 }
 
 template <typename I>