From 49534f75b55c572f94a30d9be468813592767b8b Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 2 Dec 2014 13:31:15 +0200 Subject: [PATCH] Added synchronous log flushing to disk when a signal is received. --- log_manager/log_manager.cc | 1 + server/core/gateway.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 20b753480..958eb10be 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -3123,6 +3123,7 @@ void flushall_logfiles(bool flush) */ void skygw_log_sync_all(void) { + skygw_log_write(LOGFILE_TRACE,"Starting log flushing to disk."); flushall_logfiles(true); skygw_message_send(lm->lm_logmes); skygw_message_wait(lm->lm_clientmes); diff --git a/server/core/gateway.c b/server/core/gateway.c index 379002521..183896df4 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -216,6 +216,7 @@ static void sigterm_handler (int i) { LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, "MaxScale received signal SIGTERM. Exiting."))); + skygw_log_sync_all(); shutdown_server(); } @@ -227,6 +228,7 @@ sigint_handler (int i) LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, "MaxScale received signal SIGINT. Shutting down."))); + skygw_log_sync_all(); shutdown_server(); fprintf(stderr, "\n\nShutting down MaxScale\n\n"); } @@ -269,6 +271,8 @@ sigfatal_handler (int i) } } + skygw_log_sync_all(); + /* re-raise signal to enforce core dump */ fprintf(stderr, "\n\nWriting core dump\n"); signal_set(i, SIG_DFL);