mail-transaction-log.c revision 67b9db4e0bd93ffe24cc95f609193f6f642f6448
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen/* Copyright (C) 2003-2004 Timo Sirainen */
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen/* this lock should never exist for a long time.. */
cb3ab2fd5668700a89b274a43595cfbfa1616e4bTimo Sirainenmail_transaction_log_file_open_or_create(struct mail_transaction_log *log,
cb3ab2fd5668700a89b274a43595cfbfa1616e4bTimo Sirainen const char *path);
7db7fbea5d8a07463b625f93d69166d56018dadfTimo Sirainenmail_transaction_log_file_set_corrupted(struct mail_transaction_log_file *file,
7db7fbea5d8a07463b625f93d69166d56018dadfTimo Sirainen const char *fmt, ...)
b4a7dbfb4256abcd2f983d56bd032acd55f59591Timo Sirainen if (!MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen mail_index_file_set_syscall_error(file->log->index,
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen "Corrupted transaction log file %s: %s",
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen /* this may have happened because of broken index.
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen make sure it's ok. */
a5b64f1abb1cb0a9718d5bf7f0ae808072237259Timo Sirainenmail_transaction_log_file_dotlock(struct mail_transaction_log_file *file)
4487c66123ca4830f8afbf4efcd7a260848d0e05Timo Sirainen ret = file_dotlock_create(&file->log->dotlock_settings,
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen mail_index_file_set_syscall_error(file->log->index,
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen "file_dotlock_create()");
a238c6fede2022e5a4af707107ffb8f047b7753fTimo Sirainen "Timeout while waiting for release of "
2c5c70e12365d7910848259f88eb237ce3a15947Timo Sirainen "dotlock for transaction log file %s",
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainenmail_transaction_log_file_undotlock(struct mail_transaction_log_file *file)
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen ret = file_dotlock_delete(&file->log->dotlock);
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen mail_index_file_set_syscall_error(file->log->index,
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen "Dotlock was lost for transaction log file %s",
009217abb57a24a4076092e8e4e165545747839eStephan Boschmail_transaction_log_file_lock(struct mail_transaction_log_file *file)
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
ed567dac7e55ab3e8dd53d9c86c31ebb2032d4dfTimo Sirainen if (file->log->index->lock_method == MAIL_INDEX_LOCK_DOTLOCK)
ed567dac7e55ab3e8dd53d9c86c31ebb2032d4dfTimo Sirainen return mail_transaction_log_file_dotlock(file);
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen ret = mail_index_lock_fd(file->log->index, file->filepath, file->fd,
d951320d498ae0800b677b754dde71574102123bTimo Sirainen mail_index_file_set_syscall_error(file->log->index,
d951320d498ae0800b677b754dde71574102123bTimo Sirainen "mail_index_wait_lock_fd()");
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainen "Timeout while waiting for lock for transaction log file %s",
96f89d51e8315f644f46804a9f0fc4f685ac48bfTimo Sirainenvoid mail_transaction_log_file_unlock(struct mail_transaction_log_file *file)
F_UNLCK, 0);
if (ret <= 0) {
unsigned int lock_id;
int ret;
if (ret == 0) {
if (ret <= 0)
return ret;
struct mail_transaction_log *
const char *path;
return NULL;
return NULL;
return log;
int head)
struct mail_transaction_log_file *f;
int ret;
if (ret < 0) {
if (ret == 0) {
if (head) {
unsigned int lock_id;
const char *path2;
return fd2;
if (ret < 0)
if (found) {
return fd;
const char *path,
if (fd2 < 0) {
return fd2;
struct mail_transaction_log_file **p;
*p = file;
struct mail_transaction_log_file **p;
*p = file;
int ret;
if (ret < 0) {
return ret;
static struct mail_transaction_log_file *
int ret;
if (ret < 0)
return NULL;
if (ret == 0) {
if (ret <= 0) {
return NULL;
return file;
static struct mail_transaction_log_file *
return NULL;
return file;
static struct mail_transaction_log_file *
const char *path)
int fd;
return NULL;
return NULL;
static struct mail_transaction_log_file *
const char *path)
return NULL;
if (ret <= 0) {
if (ret == 0)
return NULL;
return file;
if ((*p)->refcount != 0)
p = &(*p)->next;
*p = next;
int fd;
if (lock) {
int create_if_needed)
const char *path;
const char *path;
if (ret <= 0) {
if (ret == 0) {
const void *data;
if (hdr_size == 0) {
void *data;
int ret;
if (ret == 0) {
if (ret < 0) {
if (ret > 0)
if (ret == 0) {
if (!use_mmap) {
if (ret <= 0) {
return ret;
MADV_SEQUENTIAL) < 0) {
int ret = 0;
if (ret < 0)
return ret;