Skip to content
Permalink
Browse files

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 <qlyoung@cumulusnetworks.com>
  • Loading branch information...
qlyoung committed Aug 21, 2018
1 parent 5ab5e41 commit dce2036b6addc24c675d8ec2cd5dd30293bb2b81
Showing with 5 additions and 0 deletions.
  1. +5 −0 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;

0 comments on commit dce2036

Please sign in to comment.
You can’t perform that action at this time.