// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
+#include <signal.h>
+
#include <boost/range/adaptor/map.hpp>
#include "common/Formatter.h"
void Mirror::handle_signal(int signum)
{
- m_stopping = true;
- {
- std::lock_guard l{m_lock};
+ dout(20) << signum << dendl;
+
+ std::lock_guard l{m_lock};
+
+ switch (signum) {
+ case SIGHUP:
+ for (auto &it : m_pool_replayers) {
+ it.second->reopen_logs();
+ }
+ g_ceph_context->reopen_logs();
+ break;
+
+ case SIGINT:
+ case SIGTERM:
+ m_stopping = true;
m_cond.notify_all();
+ break;
+
+ default:
+ ceph_abort_msgf("unexpected signal %d", signum);
}
}
template <typename I>
void PoolReplayer<I>::init(const std::string& site_name) {
+ std::lock_guard locker{m_lock};
+
ceph_assert(!m_pool_replayer_thread.is_started());
// reset state
return 0;
}
+template <typename I>
+void PoolReplayer<I>::reopen_logs()
+{
+ std::lock_guard locker{m_lock};
+
+ if (m_local_rados) {
+ reinterpret_cast<CephContext *>(m_local_rados->cct())->reopen_logs();
+ }
+ if (m_remote_rados) {
+ reinterpret_cast<CephContext *>(m_remote_rados->cct())->reopen_logs();
+ }
+}
+
template <typename I>
void PoolReplayer<I>::namespace_replayer_acquire_leader(const std::string &name,
Context *on_finish) {
void restart();
void flush();
void release_leader();
+ void reopen_logs();
private:
/**
common_init_finish(g_ceph_context);
init_async_signal_handler();
- register_async_signal_handler(SIGHUP, sighup_handler);
+ register_async_signal_handler(SIGHUP, handle_signal);
register_async_signal_handler_oneshot(SIGINT, handle_signal);
register_async_signal_handler_oneshot(SIGTERM, handle_signal);
mirror->run();
cleanup:
- unregister_async_signal_handler(SIGHUP, sighup_handler);
+ unregister_async_signal_handler(SIGHUP, handle_signal);
unregister_async_signal_handler(SIGINT, handle_signal);
unregister_async_signal_handler(SIGTERM, handle_signal);
shutdown_async_signal_handler();