Skip to content

Commit

Permalink
Merge pull request #2882 from qlyoung/fix-zlog-deadlock
Browse files Browse the repository at this point in the history
lib: fix deadlock in log.c
  • Loading branch information
eqvinox committed Aug 21, 2018
2 parents 5ab5e41 + dce2036 commit f4c28c4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/log.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -868,11 +868,16 @@ int zlog_rotate(void)
save_errno = errno; save_errno = errno;
umask(oldumask); umask(oldumask);
if (zl->fp == NULL) { if (zl->fp == NULL) {

pthread_mutex_unlock(&loglock);

flog_err_sys( flog_err_sys(
LIB_ERR_SYSTEM_CALL, LIB_ERR_SYSTEM_CALL,
"Log rotate failed: cannot open file %s for append: %s", "Log rotate failed: cannot open file %s for append: %s",
zl->filename, safe_strerror(save_errno)); zl->filename, safe_strerror(save_errno));
ret = -1; ret = -1;

pthread_mutex_lock(&loglock);
} else { } else {
logfile_fd = fileno(zl->fp); logfile_fd = fileno(zl->fp);
zl->maxlvl[ZLOG_DEST_FILE] = level; zl->maxlvl[ZLOG_DEST_FILE] = level;
Expand Down

0 comments on commit f4c28c4

Please sign in to comment.