mail-transaction-log.c revision 4078733e58f156dcf5c472a40eb90ee1026407ff
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (c) 2003-2017 Dovecot authors, see the included COPYING file */
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenmail_transaction_log_set_head(struct mail_transaction_log *log,
395682d473b161c86165e7b9323ce4e45afb94bdTimo Sirainen i_assert(log->files->next != NULL || log->files == file);
395682d473b161c86165e7b9323ce4e45afb94bdTimo Sirainenmail_transaction_log_alloc(struct mail_index *index)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenstatic void mail_transaction_log_2_unlink_old(struct mail_transaction_log *log)
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen uint32_t log2_rotate_time = log->index->map->hdr.log2_rotate_time;
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen ioloop_time - (time_t)log2_rotate_time >= (time_t)log->index->log_rotate_log2_stale_secs &&
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen if (log2_rotate_time != log->index->map->hdr.log2_rotate_time) {
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen /* Write this as part of the next sync's transaction. We're
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen here because we're already opening a sync lock, so it'll
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen always happen. It's also required especially with mdbox map
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen index, which doesn't like changes done outside syncing. */
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen log->index->pending_log2_rotate_time = log2_rotate_time;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenint mail_transaction_log_open(struct mail_transaction_log *log)
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen log->filepath = i_strconcat(log->index->filepath,
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen log->filepath2 = i_strconcat(log->filepath, ".2", NULL);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen /* these settings aren't available at alloc() time, so we need to
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen set them here: */
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen (log->index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen mail_transaction_log_file_free(&log->open_file);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen file = mail_transaction_log_file_alloc(log, log->filepath);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen if ((ret = mail_transaction_log_file_open(file, &reason)) <= 0) {
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen /* leave the file for _create() */
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenint mail_transaction_log_create(struct mail_transaction_log *log, bool reset)
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen file = mail_transaction_log_file_alloc_in_memory(log);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen file = mail_transaction_log_file_alloc(log, log->filepath);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen /* remember what file we tried to open. if someone else created
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen a new file, use it instead of recreating it */
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen file->last_mtime = log->open_file->last_mtime;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen mail_transaction_log_file_free(&log->open_file);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen if (mail_transaction_log_file_create(file, reset) < 0) {
return TRUE;
return TRUE;
return TRUE;
return FALSE;
int ret;
if (reset) {
if (ret == 0) {
const char **reason_r)
const char **reason_r)
const char *reason;
int ret;
return ret;
const char *lock_reason)
const char *reason;
int ret = 0;
if (ret < 0)
return ret;
const char *lock_reason,
const char *reason;
const char *lock_reason)