From dce2036b6addc24c675d8ec2cd5dd30293bb2b81 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 21 Aug 2018 15:15:38 +0000 Subject: [PATCH] lib: fix deadlock in log.c Daemons could deadlock when log file could not be opened during a log rotation. Signed-off-by: Quentin Young --- lib/log.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/log.c b/lib/log.c index e011a78f1c..361521f568 100644 --- a/lib/log.c +++ b/lib/log.c @@ -868,11 +868,16 @@ int zlog_rotate(void) save_errno = errno; umask(oldumask); if (zl->fp == NULL) { + + pthread_mutex_unlock(&loglock); + flog_err_sys( LIB_ERR_SYSTEM_CALL, "Log rotate failed: cannot open file %s for append: %s", zl->filename, safe_strerror(save_errno)); ret = -1; + + pthread_mutex_lock(&loglock); } else { logfile_fd = fileno(zl->fp); zl->maxlvl[ZLOG_DEST_FILE] = level; -- 2.39.5