dovecot-2.2: lib-index: If transaction log is unexpectedly recre...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Nov 20 06:15:36 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/df1d0c0e7ae2
changeset: 18103:df1d0c0e7ae2
user: Timo Sirainen <tss at iki.fi>
date: Thu Nov 20 15:15:20 2014 +0900
description:
lib-index: If transaction log is unexpectedly recreated while it was locked, log a nice error.
Instead of just assert-crashing.
diffstat:
src/lib-index/mail-transaction-log-file.c | 9 +++++----
src/lib-index/mail-transaction-log.c | 13 +++++++++++--
2 files changed, 16 insertions(+), 6 deletions(-)
diffs (76 lines):
diff -r c3736d065d54 -r df1d0c0e7ae2 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Thu Nov 20 05:40:55 2014 +0900
+++ b/src/lib-index/mail-transaction-log-file.c Thu Nov 20 15:15:20 2014 +0900
@@ -817,7 +817,7 @@
/* success */
file->fd = new_fd;
mail_transaction_log_file_add_to_list(file);
- return 0;
+ return 1;
}
int mail_transaction_log_file_create(struct mail_transaction_log_file *file,
@@ -827,7 +827,7 @@
struct dotlock_settings new_dotlock_set;
struct dotlock *dotlock;
mode_t old_mask;
- int fd;
+ int fd, ret;
i_assert(!MAIL_INDEX_IS_IN_MEMORY(index));
@@ -855,12 +855,13 @@
/* either fd gets used or the dotlock gets deleted and returned fd
is for the existing file */
- if (mail_transaction_log_file_create2(file, fd, reset, &dotlock) < 0) {
+ ret = mail_transaction_log_file_create2(file, fd, reset, &dotlock);
+ if (ret < 0) {
if (dotlock != NULL)
file_dotlock_delete(&dotlock);
return -1;
}
- return 0;
+ return ret;
}
int mail_transaction_log_file_open(struct mail_transaction_log_file *file)
diff -r c3736d065d54 -r df1d0c0e7ae2 src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c Thu Nov 20 05:40:55 2014 +0900
+++ b/src/lib-index/mail-transaction-log.c Thu Nov 20 15:15:20 2014 +0900
@@ -233,6 +233,7 @@
struct mail_transaction_log_file *file;
const char *path = log->head->filepath;
struct stat st;
+ int ret;
i_assert(log->head->locked);
@@ -258,17 +259,25 @@
file->last_mtime = st.st_mtime;
file->last_size = st.st_size;
- if (mail_transaction_log_file_create(file, reset) < 0) {
+ if ((ret = mail_transaction_log_file_create(file, reset)) < 0) {
mail_transaction_log_file_free(&file);
return -1;
}
+ if (ret == 0) {
+ mail_index_set_error(log->index,
+ "Transaction log %s was recreated while we had it locked - "
+ "locking is broken (lock_method=%s)", path,
+ file_lock_method_to_str(log->index->lock_method));
+ mail_transaction_log_file_free(&file);
+ return -1;
+ }
+ i_assert(file->locked);
}
if (--log->head->refcount == 0)
mail_transaction_logs_clean(log);
else {
/* the newly created log file is already locked */
- i_assert(file->locked);
mail_transaction_log_file_unlock(log->head,
!log->index->log_sync_locked ? "rotating" :
"rotating while syncing");
More information about the dovecot-cvs
mailing list