]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
[ceph-fuse] fix ceph-fuse writing to stale log file after log rotation 7110/head
authorZhi Zhang <willzzhang@tencent.com>
Mon, 1 Feb 2016 03:03:30 +0000 (11:03 +0800)
committerZhi Zhang <willzzhang@tencent.com>
Mon, 1 Feb 2016 03:03:30 +0000 (11:03 +0800)
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 <zhangz.david@outlook.com>
src/ceph_fuse.cc
src/logrotate.conf

index 4d46639be86b098718c2603720d04634c6c3f5c6..84d4128bd9a60cf47cfeca90e410bbb134af01fe 100644 (file)
@@ -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;
index 9ae27baee45e1c8b5c6b3ae3ad22b1329f1ddbe7..df31e1d7d2bc1317926a33f1b8ee968d8e66f62d 100644 (file)
@@ -23,6 +23,7 @@
                   done
             done
         fi
+        killall -q -1 ceph-fuse || true
     endscript
     missingok
     notifempty