]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: use on exit manager to flush logs on exit
authorNoah Watkins <noahwatkins@gmail.com>
Sat, 4 Jan 2014 20:18:25 +0000 (12:18 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Sat, 4 Jan 2014 20:54:03 +0000 (12:54 -0800)
on_exit is not portable, and atexit doesn't allow parameters to be
passed to callbacks.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/log/Log.cc

index f500e3ebf0a27b6a099f05e03afe05b0eb87c69b..00870577b5b94d071cce44615764a7e5b7703d10 100644 (file)
@@ -14,6 +14,7 @@
 #include "common/Clock.h"
 #include "include/assert.h"
 #include "include/compat.h"
+#include "include/on_exit.h"
 
 #define DEFAULT_MAX_NEW    100
 #define DEFAULT_MAX_RECENT 10000
@@ -23,7 +24,9 @@
 namespace ceph {
 namespace log {
 
-static void log_on_exit(int r, void *p)
+static OnExitManager exit_callbacks;
+
+static void log_on_exit(void *p)
 {
   Log *l = *(Log **)p;
   if (l)
@@ -88,7 +91,7 @@ void Log::set_flush_on_exit()
   // assume that exit() won't race with ~Log().
   if (m_indirect_this == NULL) {
     m_indirect_this = new (Log*)(this);
-    on_exit(log_on_exit, m_indirect_this);
+    exit_callbacks.add_callback(log_on_exit, m_indirect_this);
   }
 }