mail-transaction-log-file.c revision d9fda7e3a0fa5551547ac3e3054b837fc77f4bfb
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch/* Copyright (c) 2003-2010 Dovecot authors, see the included COPYING file */
1e653c7406ec0b062c0bacfdf2e7568a3f860500Stephan Bosch#define MEMORY_LOG_NAME "(in-memory transaction log file)"
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Boschlog_file_set_syscall_error(struct mail_transaction_log_file *file,
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch return mail_index_file_set_syscall_error(file->log->index,
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Boschmail_transaction_log_mark_corrupted(struct mail_transaction_log_file *file)
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch unsigned int offset =
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch offsetof(struct mail_transaction_log_header, indexid);
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file) ||
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch /* indexid=0 marks the log file as corrupted */
1e653c7406ec0b062c0bacfdf2e7568a3f860500Stephan Bosch mail_index_file_set_syscall_error(file->log->index,
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Boschmail_transaction_log_file_set_corrupted(struct mail_transaction_log_file *file,
d45ab3fff7c47f1719b9cd310228c0dac2bdd1b2Timo Sirainen const char *fmt, ...)
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch "Corrupted transaction log file %s seq %u: %s "
d82ad7143c057c565e1fd5f3580645556ed0bcc9Stephan Bosch t_strdup_vprintf(fmt, va), file->sync_offset);
92c2272787b74eb000f05a926e9103a25a6a0dc0Stephan Boschmail_transaction_log_file_alloc(struct mail_transaction_log *log,
5394bed8aaef2a6c1c870a34a23a7824e1f370bbStephan Bosch file = i_new(struct mail_transaction_log_file, 1);
a952a4444e46e107b15ab1bd0e8b63a29f94b123Timo Sirainenvoid mail_transaction_log_file_free(struct mail_transaction_log_file **_file)
c911297407bdcc7c7936305eb8f791b450d6375cTimo Sirainen struct mail_transaction_log_file *file = *_file;
if (*p == file) {
struct mail_transaction_log_file **p;
*p = file;
#if !WORDS_BIGENDIAN
MAIL_INDEX_SYNC_HANDLER_HEAD) <= 0)
struct mail_transaction_log_file *
return NULL;
return file;
int ret;
if (ret > 0) {
if (ret < 0) {
int ret;
if (ret < 0) {
if (ret == 0) {
unsigned int lock_timeout_secs;
int ret;
if (ret > 0) {
if (ret < 0) {
unsigned int lock_time;
static ssize_t
pos = 0;
if (ret > 0)
bool ignore_estale)
struct mail_transaction_log_file *f;
int ret;
if (ret < 0) {
#if !WORDS_BIGENDIAN
ret = 0;
return ret;
bool ignore_estale)
return TRUE;
return FALSE;
const char *path2;
bool rename_existing;
if (reset)
FALSE) > 0 &&
if (reset) {
if (ret < 0)
if (rename_existing) {
path2);
bool reset)
int fd;
bool check_existing)
bool ignore_estale;
int ret;
else if (check_existing &&
if (ret > 0) {
if (ret == 0) {
i == MAIL_INDEX_ESTALE_RETRY_COUNT) {
const unsigned int offset_pos =
sizeof(tail_offset));
if (*cur_modseq != 0) {
const unsigned int modseq_ext_len =
modseq_ext_len) == 0) {
case MAIL_TRANSACTION_APPEND:
case MAIL_TRANSACTION_MODSEQ_UPDATE: {
static struct modseq_cache *
if (idx > 0) {
static struct modseq_cache *
return NULL;
best = i;
return NULL;
static struct modseq_cache *
return NULL;
best = i;
return NULL;
int ret;
if (ret <= 0) {
if (ret < 0)
int ret;
if (ret <= 0) {
if (ret < 0)
unsigned int trans_size)
int ret;
sizeof(*hdr));
if (ret != 0)
const void *data;
if (trans_size == 0) {
trans_size = 0;
if (trans_size != 0) {
void *data;
if (ret > 0) {
if (ret == 0) {
void *data;
if (ret > 0)
if (ret < 0) {
return TRUE;
return TRUE;
return FALSE;
int ret;
if (ret <= 0)
return ret;
return ret;
MADV_SEQUENTIAL) < 0)
int ret;
if (ret > 0)
FALSE);
} while (ret == 0);
int ret;
end_offset) == 0)
*file)