Mercurial > dovecot > core-2.2
changeset 21354:30ef85789908
lib-index: Fix assert-crash if .log creation unexpectedly fails at the end
Pretty much the only reason for this to happen is if the index directory
was deleted while another process still had the index open. Even this
doesn't normally trigger this crash, because there are other checks earlier
that usually catch it. So it crashes only in some race conditions.
Fixes:
Error: rename(.../dovecot.index.log.newlock, .../dovecot.index.log) failed: No such file or directory
Panic: file mail-transaction-log-file.c: line 105 (mail_transaction_log_file_free): assertion failed: (!file->locked)
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 19 Dec 2016 15:31:50 +0200 |
parents | e14cd8964879 |
children | 788bd1e04e3d |
files | src/lib-index/mail-transaction-log-file.c |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-file.c Tue Dec 20 13:40:17 2016 +0200 +++ b/src/lib-index/mail-transaction-log-file.c Mon Dec 19 15:31:50 2016 +0200 @@ -786,7 +786,7 @@ file->fd = new_fd; ret = mail_transaction_log_file_stat(file, FALSE); - if (need_lock) { + if (need_lock && ret == 0) { /* we'll need to preserve the lock */ if (mail_transaction_log_file_lock(file) < 0) ret = -1; @@ -821,8 +821,12 @@ } if (file_dotlock_replace(dotlock, - DOTLOCK_REPLACE_FLAG_DONT_CLOSE_FD) <= 0) + DOTLOCK_REPLACE_FLAG_DONT_CLOSE_FD) <= 0) { + /* need to unlock to avoid assert-crash in + mail_transaction_log_file_free() */ + mail_transaction_log_file_unlock(file, "creation failed"); return -1; + } /* success */ file->fd = new_fd;