Make PeerReplayer::m_stopping as std::<atomic> and make it
independant of m_lock. This helps 'm_stopping' to be used
as predicate in any conditional wait which doesn't use
m_lock.
Fixes: https://tracker.ceph.com/issues/73452
Signed-off-by: Kotresh HR <khiremat@redhat.com>
void PeerReplayer::shutdown() {
dout(20) << dendl;
+ bool expected = false;
+ if (!m_stopping.compare_exchange_strong(expected, true)) {
+ dout(1) << ": shutdown is already in progress - return"<< dendl;
+ return;
+ }
{
- std::scoped_lock locker(m_lock);
- ceph_assert(!m_stopping);
- m_stopping = true;
- m_cond.notify_all();
+ std::scoped_lock lock(m_lock);
+ m_cond.notify_all(); //wake up shutdown wait
}
for (auto &replayer : m_replayers) {
};
bool is_stopping() {
- return m_stopping;
+ return m_stopping.load(std::memory_order_acquire);
}
struct Replayer;
ceph::condition_variable m_cond;
RadosRef m_remote_cluster;
MountRef m_remote_mount;
- bool m_stopping = false;
+ std::atomic<bool> m_stopping{false};
SnapshotReplayers m_replayers;
SnapshotDataReplayers m_data_replayers;