return -1;
mail_index_set_error(index,
- "Timeout while waiting for shared lock for index file %s",
- index->filepath);
+ "Timeout (%us) while waiting for shared lock for index file %s",
+ timeout_secs, index->filepath);
index->index_lock_timeout = TRUE;
return -1;
}
#define LOG_PREFETCH IO_BLOCK_SIZE
#define MEMORY_LOG_NAME "(in-memory transaction log file)"
+#define LOG_NEW_DOTLOCK_SUFFIX ".newlock"
static int
log_file_set_syscall_error(struct mail_transaction_log_file *file,
static int
mail_transaction_log_file_dotlock(struct mail_transaction_log_file *file)
{
+ struct dotlock_settings dotlock_set;
int ret;
if (file->log->dotlock_count > 0)
ret = 1;
else {
- ret = file_dotlock_create(&file->log->dotlock_settings,
- file->filepath, 0,
+ mail_transaction_log_get_dotlock_set(file->log, &dotlock_set);
+ ret = file_dotlock_create(&dotlock_set, file->filepath, 0,
&file->log->dotlock);
}
if (ret > 0) {
}
mail_index_set_error(file->log->index,
- "Timeout while waiting for "
+ "Timeout (%us) while waiting for "
"dotlock for transaction log file %s",
- file->filepath);
+ dotlock_set.timeout, file->filepath);
file->log->index->index_lock_timeout = TRUE;
return -1;
}
}
mail_index_set_error(file->log->index,
- "Timeout while waiting for lock for transaction log file %s",
- file->filepath);
+ "Timeout (%us) while waiting for lock for "
+ "transaction log file %s",
+ lock_timeout_secs, file->filepath);
file->log->index->index_lock_timeout = TRUE;
return -1;
}
bool reset)
{
struct mail_index *index = file->log->index;
+ struct dotlock_settings new_dotlock_set;
struct dotlock *dotlock;
mode_t old_mask;
int fd;
return -1;
}
+ mail_transaction_log_get_dotlock_set(file->log, &new_dotlock_set);
+ new_dotlock_set.lock_suffix = LOG_NEW_DOTLOCK_SUFFIX;
+
/* With dotlocking we might already have path.lock created, so this
filename has to be different. */
old_mask = umask(index->mode ^ 0666);
- fd = file_dotlock_open(&file->log->new_dotlock_settings,
- file->filepath, 0, &dotlock);
+ fd = file_dotlock_open(&new_dotlock_set, file->filepath, 0, &dotlock);
umask(old_mask);
if (fd == -1)
#define MAIL_TRANSACTION_LOG_VIEW_H
#include "buffer.h"
-#include "file-dotlock.h"
#include "mail-transaction-log.h"
+struct dotlock_settings;
+
/* Synchronization can take a while sometimes, especially when copying lots of
mails. */
#define MAIL_TRANSCATION_LOG_LOCK_TIMEOUT (3*60)
struct mail_transaction_log_file *open_file;
unsigned int dotlock_count;
- struct dotlock_settings dotlock_settings, new_dotlock_settings;
struct dotlock *dotlock;
unsigned int nfs_flush:1;
const char *fmt, ...)
ATTR_FORMAT(2, 3);
+void mail_transaction_log_get_dotlock_set(struct mail_transaction_log *log,
+ struct dotlock_settings *set_r);
+
struct mail_transaction_log_file *
mail_transaction_log_file_alloc_in_memory(struct mail_transaction_log *log);
struct mail_transaction_log_file *
#include <stdio.h>
#include <sys/stat.h>
-#define LOG_NEW_DOTLOCK_SUFFIX ".newlock"
-
static void
mail_transaction_log_set_head(struct mail_transaction_log *log,
struct mail_transaction_log_file *file)
log = i_new(struct mail_transaction_log, 1);
log->index = index;
-
- log->dotlock_settings.timeout =
- I_MIN(MAIL_TRANSCATION_LOG_LOCK_TIMEOUT,
- index->max_lock_timeout_secs);;
- log->dotlock_settings.stale_timeout =
- MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT;
-
- log->new_dotlock_settings = log->dotlock_settings;
- log->new_dotlock_settings.lock_suffix = LOG_NEW_DOTLOCK_SUFFIX;
return log;
}
set them here: */
log->nfs_flush =
(log->index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
- log->dotlock_settings.use_excl_lock =
- log->dotlock_settings.nfs_flush =
- (log->index->flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0;
- log->dotlock_settings.nfs_flush =
- log->new_dotlock_settings.nfs_flush =
- log->nfs_flush;
if (log->open_file != NULL)
mail_transaction_log_file_free(&log->open_file);
*mtime_r = st.st_mtime;
return 0;
}
+
+void mail_transaction_log_get_dotlock_set(struct mail_transaction_log *log,
+ struct dotlock_settings *set_r)
+{
+ struct mail_index *index = log->index;
+
+ memset(set_r, 0, sizeof(*set_r));
+ set_r->timeout = I_MIN(MAIL_TRANSCATION_LOG_LOCK_TIMEOUT,
+ index->max_lock_timeout_secs);
+ set_r->stale_timeout = MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT;
+ set_r->nfs_flush = (index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
+ set_r->use_excl_lock =
+ (index->flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0;
+}