mail-transaction-log.c revision 837ea26bce080f166b2ec90d901faeff58beb22b
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen/* Copyright (c) 2003-2007 Dovecot authors, see the included COPYING file */
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainenmail_transaction_log_set_head(struct mail_transaction_log *log,
847aeef259d42e2f14cf126699e28291e6e1fb53Timo Sirainen i_assert(log->files->next != NULL || log->files == file);
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainenmail_transaction_log_alloc(struct mail_index *index)
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen log->dotlock_settings.use_excl_lock = index->use_excl_dotlocks;
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen log->dotlock_settings.nfs_flush = index->nfs_flush;
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen log->dotlock_settings.timeout = MAIL_TRANSCATION_LOG_LOCK_TIMEOUT;
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen log->new_dotlock_settings = log->dotlock_settings;
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen log->new_dotlock_settings.lock_suffix = LOG_NEW_DOTLOCK_SUFFIX;
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainenstatic void mail_transaction_log_2_unlink_old(struct mail_transaction_log *log)
847aeef259d42e2f14cf126699e28291e6e1fb53Timo Sirainen if (st.st_mtime + MAIL_TRANSACTION_LOG2_STALE_SECS <= ioloop_time) {
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainenint mail_transaction_log_open(struct mail_transaction_log *log)
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen mail_transaction_log_file_free(&log->open_file);
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen file = mail_transaction_log_file_alloc(log, path);
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen if ((ret = mail_transaction_log_file_open(file, FALSE)) <= 0) {
2a3fc652e13a574ca14ff2405b5c29a59232db49Timo Sirainen /* leave the file for _create() */
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainenint mail_transaction_log_create(struct mail_transaction_log *log)
812ac1e2570c600a086c09b24d250224a822a97dTimo Sirainen file = mail_transaction_log_file_alloc_in_memory(log);
d65a556a5ec078cd7f1d0060adb16fc860d66b27Timo Sirainen file = mail_transaction_log_file_alloc(log, path);
e4ded29bff0662a590c2439ef2df8cda8a7cdd9bTimo Sirainen /* remember what file we tried to open. if someone else created
e4ded29bff0662a590c2439ef2df8cda8a7cdd9bTimo Sirainen a new file, use it instead of recreating it */
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainen file->last_mtime = log->open_file->last_mtime;
bc2d4f1c18222a3bd2a6b2b8b5f6abb560a865b3Timo Sirainen mail_transaction_log_file_free(&log->open_file);
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainen if (mail_transaction_log_file_create(file, FALSE) < 0) {
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainenvoid mail_transaction_log_close(struct mail_transaction_log *log)
bc2d4f1c18222a3bd2a6b2b8b5f6abb560a865b3Timo Sirainen mail_transaction_log_file_free(&log->open_file);
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainenvoid mail_transaction_log_free(struct mail_transaction_log **_log)
af6c7862e6160ffaecec458f4cec43b94272ad57Timo Sirainenvoid mail_transaction_log_move_to_memory(struct mail_transaction_log *log)
055f4599bba1874fa1148a8fa488517fa077619cTimo Sirainen mail_transaction_log_file_move_to_memory(log->head);
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainen file = mail_transaction_log_file_alloc_in_memory(log);
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainenvoid mail_transaction_log_indexid_changed(struct mail_transaction_log *log)
345253fb28498b2e0a60f4a2a8644c65feee7e75Timo Sirainen for (file = log->files; file != NULL; file = file->next) {
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainen if (file->hdr.indexid != log->index->indexid) {
72388282bf6718c39af34cfcf51438910f9d62daTimo Sirainen "indexid changed: %u -> %u",
if (reset) {
const char *path;
const char *path;
int ret;
return ret;
int ret = 0;
if (ret < 0)
return ret;