From 7aa980528c1c59d91303cc75ca264c17e309c60b Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Sat, 4 Jan 2014 12:18:25 -0800 Subject: [PATCH] log: use on exit manager to flush logs on exit on_exit is not portable, and atexit doesn't allow parameters to be passed to callbacks. Signed-off-by: Noah Watkins --- src/log/Log.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/log/Log.cc b/src/log/Log.cc index f500e3ebf0a27..00870577b5b94 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -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); } } -- 2.39.5