Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit
9ddf111506611a596c713ffe861a41aeda05e7a5)
Conflicts:
src/tools/rbd_mirror/Mirror.cc (std::lock_guard vs Mutex::Locker, ceph_abort_msgf does not exist)
src/tools/rbd_mirror/PoolReplayer.cc (std::lock_guard vs Mutex::Locker)
// -*- 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;
- {
- Mutex::Locker l(m_lock);
+ dout(20) << signum << dendl;
+
+ Mutex::Locker 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.Signal();
+ break;
+
+ default:
+ ceph_abort();
}
}
template <typename I>
void PoolReplayer<I>::init()
{
+ Mutex::Locker l(m_lock);
+
assert(!m_pool_replayer_thread.is_started());
// reset state
m_instance_replayer->stop();
}
+template <typename I>
+void PoolReplayer<I>::reopen_logs()
+{
+ Mutex::Locker l(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>::print_status(Formatter *f, stringstream *ss)
{
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();