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>
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>