: SafeTimer(cct, timer_lock, true) {
init();
}
-
- ~SafeTimerSingleton() {
- std::scoped_lock locker(timer_lock);
- shutdown();
- }
};
class ThreadPoolSingleton : public ThreadPool {
start();
}
-
- ~ThreadPoolSingleton() override {
- work_queue->drain();
- delete work_queue;
-
- stop();
- }
};
} // anonymous namespace
"cephfs::mirror::thread_pool", false, cct));
auto safe_timer = &(cct->lookup_or_create_singleton_object<SafeTimerSingleton>(
"cephfs::mirror::safe_timer", false, cct));
+ m_thread_pool = thread_pool;
m_work_queue = thread_pool->work_queue;
m_timer = safe_timer;
m_timer_lock = &safe_timer->timer_lock;
Mirror::~Mirror() {
dout(10) << dendl;
+ {
+ std::scoped_lock timer_lock(*m_timer_lock);
+ m_timer->shutdown();
+ }
+
+ m_work_queue->drain();
+ delete m_work_queue;
+ {
+ std::scoped_lock locker(m_lock);
+ m_thread_pool->stop();
+ m_cluster_watcher.reset();
+ }
}
int Mirror::init_mon_client() {
dout(20) << dendl;
m_monc->set_messenger(m_msgr);
+ m_msgr->add_dispatcher_head(m_monc);
m_monc->set_want_keys(CEPH_ENTITY_TYPE_MON);
int r = m_monc->init();
dout(20) << dendl;
std::unique_lock locker(m_lock);
- if (m_mirror_actions.empty()) {
- return;
- }
-
m_stopping = true;
m_cond.notify_all();
- m_cond.wait(locker, [this] {return m_stopped;});
}
void Mirror::handle_signal(int signum) {
dout(10) << ": signal=" << signum << dendl;
ceph_assert(signum == SIGTERM || signum == SIGINT);
shutdown();
- ::exit(0);
}
void Mirror::handle_enable_mirroring(const Filesystem &filesystem,
dout(10) << ": shutdown filesystem=" << filesystem << ", r=" << r << dendl;
}
}
-
- m_stopped = true;
- m_cond.notify_all();
}
} // namespace mirror
#include <vector>
#include "common/ceph_mutex.h"
+#include "common/WorkQueue.h"
#include "mds/FSMap.h"
#include "ClusterWatcher.h"
#include "FSMirror.h"
Messenger *m_msgr;
ClusterListener m_listener;
+ ThreadPool *m_thread_pool = nullptr;
ContextWQ *m_work_queue = nullptr;
SafeTimer *m_timer = nullptr;
ceph::mutex *m_timer_lock = nullptr;
Context *m_timer_task = nullptr;
bool m_stopping = false;
- bool m_stopped = false;
std::unique_ptr<ClusterWatcher> m_cluster_watcher;
std::map<Filesystem, MirrorAction> m_mirror_actions;