///////////////////////////// DoutStreambuf /////////////////////////////
template <typename charT, typename traits>
DoutStreambuf<charT, traits>::DoutStreambuf()
- : flags(0), ofd(-1)
+ : flags(0), ofd(-1), rlr(false)
{
// Initialize get pointer to zero so that underflow is called on the first read.
this->setg(0, 0, 0);
// Initialize output_buffer
_clear_output_buffer();
+
+ pthread_spin_init(&rlr_lock, PTHREAD_PROCESS_PRIVATE);
}
template <typename charT, typename traits>
TEMP_FAILURE_RETRY(::close(ofd));
ofd = -1;
}
+ pthread_spin_destroy(&rlr_lock);
}
// This function is called when the output buffer is filled.
assert(0);
}
+template <typename charT, typename traits>
+void DoutStreambuf<charT, traits>::
+request_log_reopen(void)
+{
+ pthread_spin_lock(&rlr_lock);
+ rlr = true;
+ pthread_spin_unlock(&rlr_lock);
+}
+
+template <typename charT, typename traits>
+void DoutStreambuf<charT, traits>::
+handle_log_reopen_requests(const md_config_t *conf)
+{
+ bool need;
+ pthread_spin_lock(&rlr_lock);
+ need = rlr;
+ pthread_spin_unlock(&rlr_lock);
+ if (!need)
+ return;
+ std::set <std::string> changed;
+ const char **keys = get_tracked_conf_keys();
+ for (const char **k = keys; *k; ++k) {
+ changed.insert(*k);
+ }
+ handle_conf_change(conf, changed);
+}
+
template <typename charT, typename traits>
void DoutStreambuf<charT, traits>::_clear_output_buffer()
{
// (if those sinks are active)
void dout_emergency_to_file_and_syslog(const char * const str) const;
+ // The next two functions are used to implement the Ceph daemons'
+ // SIGHUP handling.
+
+ // Set the request_log_reopen bit.
+ // Signal-safe.
+ void request_log_reopen(void);
+
+ // Read the request_log_reopen bit.
+ // If it's set, reopen the log.
+ // This is meant to be called from an event loop. Not signal-safe.
+ void handle_log_reopen_requests(const md_config_t *conf);
+
protected:
// Called when the buffer fills up
virtual int_type overflow(int_type c);
std::string opath;
std::string symlink_dir;
std::string isym_path;
+
+ pthread_spinlock_t rlr_lock;
+ bool rlr;
};
// Secret evil interfaces for writing logs without taking the lock.
*/
#include "common/BackTrace.h"
+#include "common/DoutStreambuf.h"
#include "common/ProfLogger.h"
#include "common/pidfile.h"
#include "common/debug.h"
void sighup_handler(int signum)
{
- /* In the past, users had to send a SIGHUP to the process after making a
- * change to certain parts of the logging configuration. Now, this is no
- * longer necessary. Now we want to ignore SIGHUP signals.
- */
+ g_conf._doss->request_log_reopen();
}
static void reraise_fatal(int signum)
#include "auth/KeyRing.h"
#include "common/config.h"
+#include "common/DoutStreambuf.h"
#include "perfglue/cpu_profiler.h"
#include "perfglue/heap_profiler.h"
if (snapserver)
snapserver->check_osd_map(false);
}
+
+ g_conf._doss->handle_log_reopen_requests(&g_conf);
}
#include "common/ceph_argparse.h"
#include "common/Timer.h"
#include "common/Clock.h"
+#include "common/DoutStreambuf.h"
#include "include/color.h"
#include "OSDMonitor.h"
}
}
+ g_conf._doss->handle_log_reopen_requests(&g_conf);
+
new_tick();
}
#include "messages/MWatchNotify.h"
+#include "common/DoutStreambuf.h"
#include "common/ProfLogger.h"
#include "common/ProfLogType.h"
#include "common/Timer.h"
dispatch_running = false;
dispatch_cond.Signal();
}
+
+ g_conf._doss->handle_log_reopen_requests(&g_conf);
}
// =========================================