From: Jason Dillaman Date: Sun, 22 Dec 2019 22:16:17 +0000 (-0500) Subject: rbd-mirror: clear init/shutdown context before completion X-Git-Tag: v15.1.0~352^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8542da0991c5ad35d76b83044492db037906ac66;p=ceph-ci.git rbd-mirror: clear init/shutdown context before completion 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 --- diff --git a/src/tools/rbd_mirror/image_replayer/journal/Replayer.cc b/src/tools/rbd_mirror/image_replayer/journal/Replayer.cc index 59c2ab239b8..be7ec3061bd 100644 --- a/src/tools/rbd_mirror/image_replayer/journal/Replayer.cc +++ b/src/tools/rbd_mirror/image_replayer/journal/Replayer.cc @@ -596,8 +596,13 @@ void Replayer::handle_wait_for_in_flight_ops(int r) { ReplayStatusFormatter::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