From 0cda00f08d3d620be89830bad9d0e252648388e9 Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Tue, 25 Sep 2018 03:42:47 -0400 Subject: logging: fix file handle leak when calls glfs_set_logging more times Closes the log file and reopens it to prevent leakage of file handles. Change-Id: Idfaa479961bb0088004d0d5558bdb0eb32cff632 updates: bz#1626313 Signed-off-by: Kinglong Mee --- libglusterfs/src/logging.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index 0c5906f40a3..b57d47a7553 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -720,6 +720,13 @@ gf_log_init(void *data, const char *file, const char *ident) GF_FREE(ctx->log.filename); ctx->log.filename = NULL; + /* close and reopen logfile for log rotate */ + if (ctx->log.logfile) { + fclose(ctx->log.logfile); + ctx->log.logfile = NULL; + ctx->log.gf_log_logfile = NULL; + } + if (strcmp(file, "-") == 0) { int dupfd = -1; -- cgit