summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKinglong Mee <mijinlong@open-fs.com>2018-09-25 03:42:47 -0400
committerAmar Tumballi <amarts@redhat.com>2018-10-10 05:49:17 +0000
commit0cda00f08d3d620be89830bad9d0e252648388e9 (patch)
treef9e99bf8edb0e45127c82e5c8ee42dae188f9590 /libglusterfs
parent21c6b3e5ab47b615f0b18a27ce74285490f43a7a (diff)
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 <mijinlong@open-fs.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/logging.c7
1 files changed, 7 insertions, 0 deletions
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;