]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix deadlock in log.c 2882/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 21 Aug 2018 15:15:38 +0000 (15:15 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 21 Aug 2018 15:15:38 +0000 (15:15 +0000)
Daemons could deadlock when log file could not be opened during a log
rotation.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/log.c

index e011a78f1c3a38e4b267aab9e0a1e1f9e65ef20e..361521f56823335f749f3aa059ed62efedb8939e 100644 (file)
--- 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;