From 8af97016bb0e5c8597d60ac986fe3f6fd1c8ee4f Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Tue, 11 Nov 2014 18:33:17 +0200 Subject: [PATCH] Dummy for skygw_log_rotate. --- log_manager/log_manager.cc | 40 ++++++++++++++++++++++++++++++++++---- log_manager/log_manager.h | 1 + 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index eef43efd0..924eaba15 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -801,7 +801,7 @@ static int logmanager_write_log( if (wp[safe_str_len-2] == '\n') { wp[safe_str_len-2]=' '; - } + } wp[safe_str_len-1] = '\n'; blockbuf_unregister(bb); @@ -1428,6 +1428,37 @@ return_err: return err; } + +int skygw_log_rotate( + logfile_id_t id) +{ + int err = 0; + goto return_err; + + va_list valist; /**< Dummy, must be present but it is not processed */ + + if (!logmanager_register(false)) { + ss_dfprintf(stderr, + "Can't register to logmanager, rotating failed\n"); + goto return_err; + } + CHK_LOGMANAGER(lm); + err = logmanager_write_log(id, true, false, false, 0, NULL, valist); + + if (err != 0) { + fprintf(stderr, "skygw_log_flush failed.\n"); + goto return_unregister; + } + + return_unregister: + logmanager_unregister(); +return_err: + return err; +} + + + + /** * @node Register as a logging client to logmanager. * @@ -2602,7 +2633,8 @@ static void* thr_filewriter_fun( flushall_logfiles = skygw_thread_must_exit(thr); /** Process all logfiles which have buffered writes. */ - for (i=LOGFILE_FIRST; i<=LOGFILE_LAST; i <<= 1) { + for (i=LOGFILE_FIRST; i<=LOGFILE_LAST; i <<= 1) + { retry_flush_on_exit: /** * Get file pointer of current logfile. @@ -2651,14 +2683,14 @@ static void* thr_filewriter_fun( * buffer is at least half-full * -> write to disk */ - while(bb->bb_refcount > 0) { + while(bb->bb_refcount > 0) + { simple_mutex_unlock( &bb->bb_mutex); simple_mutex_lock( &bb->bb_mutex, true); } - err = skygw_file_write( file, (void *)bb->bb_buf, diff --git a/log_manager/log_manager.h b/log_manager/log_manager.h index 776b6cbb7..9266e865e 100644 --- a/log_manager/log_manager.h +++ b/log_manager/log_manager.h @@ -75,6 +75,7 @@ void skygw_logmanager_exit(void); void skygw_log_done(void); int skygw_log_write(logfile_id_t id, const char* format, ...); int skygw_log_flush(logfile_id_t id); +int skygw_log_rotate(logfile_id_t id); int skygw_log_write_flush(logfile_id_t id, const char* format, ...); int skygw_log_enable(logfile_id_t id); int skygw_log_disable(logfile_id_t id);