[dovecot-cvs] dovecot/src/lib-index mail-transaction-log.c, 1.20,
1.21
cras at procontrol.fi
cras at procontrol.fi
Tue May 11 00:01:33 EEST 2004
Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv14543
Modified Files:
mail-transaction-log.c
Log Message:
some minor fixes
Index: mail-transaction-log.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mail-transaction-log.c 10 May 2004 18:39:33 -0000 1.20
+++ mail-transaction-log.c 10 May 2004 21:01:31 -0000 1.21
@@ -33,7 +33,8 @@
static struct mail_transaction_log_file *
mail_transaction_log_file_open_or_create(struct mail_transaction_log *log,
const char *path);
-static int mail_transaction_log_rotate(struct mail_transaction_log *log);
+static int mail_transaction_log_rotate(struct mail_transaction_log *log,
+ int lock_type);
static int
mail_transaction_log_file_lock(struct mail_transaction_log_file *file,
@@ -89,7 +90,7 @@
ret = -1;
else if (INDEX_HAS_MISSING_LOGS(index, file)) {
/* broken - fix it by creating a new log file */
- ret = mail_transaction_log_rotate(log);
+ ret = mail_transaction_log_rotate(log, F_UNLCK);
}
}
@@ -519,11 +520,12 @@
log->head = NULL;
}
-static int mail_transaction_log_rotate(struct mail_transaction_log *log)
+static int mail_transaction_log_rotate(struct mail_transaction_log *log,
+ int lock_type)
{
struct mail_transaction_log_file *file;
struct stat st;
- int fd, lock_type;
+ int fd;
if (fstat(log->head->fd, &st) < 0) {
mail_index_file_set_syscall_error(log->index,
@@ -541,7 +543,6 @@
if (file == NULL)
return -1;
- lock_type = log->head->lock_type;
if (lock_type != F_UNLCK) {
if (mail_transaction_log_file_lock(file, lock_type) < 0) {
file->refcount--;
@@ -549,6 +550,7 @@
return -1;
}
}
+ i_assert(file->lock_type == lock_type);
if (--log->head->refcount == 0)
mail_transaction_logs_clean(log);
@@ -568,7 +570,7 @@
if (mail_index_lock_shared(log->index, TRUE, &lock_id) < 0)
return -1;
- ret = mail_transaction_log_rotate(log);
+ ret = mail_transaction_log_rotate(log, F_UNLCK);
mail_index_unlock(log->index, lock_id);
return ret;
}
@@ -833,6 +835,7 @@
break;
}
+ i_assert(log->head->lock_type == F_UNLCK);
if (file != NULL) {
if (mail_transaction_log_file_lock(file, F_UNLCK) < 0)
return -1;
@@ -1118,7 +1121,7 @@
log->head->last_mtime <
ioloop_time - MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME) {
/* everything synced in index, we can rotate. */
- if (mail_transaction_log_rotate(log) < 0) {
+ if (mail_transaction_log_rotate(log, F_WRLCK) < 0) {
if (!log->index->log_locked) {
(void)mail_transaction_log_file_lock(log->head,
F_UNLCK);
More information about the dovecot-cvs
mailing list