From f209819fb676eadf099cc764e3ed3b20fd17b688 Mon Sep 17 00:00:00 2001 From: Zhi Zhang Date: Mon, 1 Feb 2016 11:03:30 +0800 Subject: [PATCH] [ceph-fuse] fix ceph-fuse writing to stale log file after log rotation This fix should be applied to hammer branch. It can't be directly applied to master branch, because logrotate.conf is changed on matser since ceph-osd, ceph-mon, etc, is controlled by systemd with user/group as 'ceph' by default, while ceph-fuse might be started as root privilege by external users. Signed-off-by: Zhi Zhang --- src/ceph_fuse.cc | 7 +++++++ src/logrotate.conf | 1 + 2 files changed, 8 insertions(+) diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index 4d46639be86..84d4128bd9a 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -31,6 +31,7 @@ using namespace std; #include "common/Timer.h" #include "common/ceph_argparse.h" #include "global/global_init.h" +#include "global/signal_handler.h" #include "common/safe_io.h" #ifndef DARWIN @@ -211,6 +212,9 @@ int main(int argc, const char **argv, const char *envp[]) { goto out_client_unmount; } + init_async_signal_handler(); + register_async_signal_handler(SIGHUP, sighup_handler); + cerr << "ceph-fuse[" << getpid() << "]: starting fuse" << std::endl; tester.init(cfuse, client); tester.create(); @@ -249,6 +253,9 @@ int main(int argc, const char **argv, const char *envp[]) { free(newargv); delete mc; + + unregister_async_signal_handler(SIGHUP, sighup_handler); + shutdown_async_signal_handler(); //cout << "child done" << std::endl; return r; diff --git a/src/logrotate.conf b/src/logrotate.conf index 9ae27baee45..df31e1d7d2b 100644 --- a/src/logrotate.conf +++ b/src/logrotate.conf @@ -23,6 +23,7 @@ done done fi + killall -q -1 ceph-fuse || true endscript missingok notifempty -- 2.47.3