mails. */
#define MAIL_TRANSCATION_LOG_LOCK_TIMEOUT (3*60)
#define MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT (3*60)
+#define MAIL_TRANSACTION_LOG_LOCK_WARN_SECS 30
/* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */
#define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*32)
int mail_transaction_log_lock_head(struct mail_transaction_log *log)
{
struct mail_transaction_log_file *file;
+ time_t lock_wait_started, lock_secs = 0;
int ret = 0;
if (!log->log_2_unlink_checked) {
can lock it and don't see another file, we can be sure no-one is
creating a new log at the moment */
+ lock_wait_started = time(NULL);
for (;;) {
file = log->head;
if (mail_transaction_log_file_lock(file) < 0)
if (ret == 0 && log->head == file) {
/* success */
+ lock_secs = file->lock_created - lock_wait_started;
break;
}
/* try again */
}
+ if (lock_secs > MAIL_TRANSACTION_LOG_LOCK_WARN_SECS) {
+ i_warning("Locking transaction log file %s took %ld seconds",
+ log->head->filepath, (long)lock_secs);
+ }
i_assert(ret < 0 || log->head != NULL);
return ret;