[dovecot-cvs] dovecot/src/lib-index mail-transaction-log.c, 1.111.2.16, 1.111.2.17

tss at dovecot.org tss at dovecot.org
Fri Mar 16 17:44:57 EET 2007


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv2773

Modified Files:
      Tag: branch_1_0
	mail-transaction-log.c 
Log Message:
Creating initial transaction log file leaked memory, created the file
twice and caused potential locking problems.



Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.111.2.16
retrieving revision 1.111.2.17
diff -u -d -r1.111.2.16 -r1.111.2.17
--- mail-transaction-log.c	15 Mar 2007 01:05:13 -0000	1.111.2.16
+++ mail-transaction-log.c	16 Mar 2007 15:44:55 -0000	1.111.2.17
@@ -38,6 +38,9 @@
 				 bool lock, dev_t dev, ino_t ino,
 				 uoff_t file_size);
 static int
+mail_transaction_log_file_fd_open_or_create(struct mail_transaction_log_file
+					    	*file, bool try_retry);
+static int
 mail_transaction_log_file_read(struct mail_transaction_log_file *file,
 			       uoff_t offset);
 
@@ -311,7 +314,9 @@
 			memset(&st, 0, sizeof(st));
 		if (mail_transaction_log_file_create(file, FALSE,
 						     st.st_dev, st.st_ino,
-						     st.st_size) < 0) {
+						     st.st_size) < 0 ||
+		    mail_transaction_log_file_fd_open_or_create(file,
+								FALSE) < 0) {
 			mail_transaction_log_file_free(file);
 			file = NULL;
 		}
@@ -330,6 +335,7 @@
 	}
 	file->refcount++;
 	log->head = file;
+	i_assert(log->files != NULL);
 
 	if (index->fd != -1 &&
 	    INDEX_HAS_MISSING_LOGS(index, log->head)) {
@@ -959,6 +965,7 @@
 		mail_transaction_log_file_unlock(log->head);
 
 	i_assert(log->head != file);
+	i_assert(log->files != NULL);
 	log->head = file;
 	log->head->refcount++;
 	return 0;
@@ -1004,6 +1011,7 @@
 	if (--log->head->refcount == 0)
 		mail_transaction_logs_clean(log);
 
+	i_assert(log->files != NULL);
 	log->head = file;
 	log->head->refcount++;
 	return 0;



More information about the dovecot-cvs mailing list