changeset 5658:115d13bb1a47 HEAD

Combined mail_transaction_log_file_add_to_head() to mail_transaction_log_file_add_to_list()
author Timo Sirainen <tss@iki.fi>
date Wed, 23 May 2007 19:07:12 +0300
parents 42a62cd60308
children b118198fbfa3
files src/lib-index/mail-transaction-log.c
diffstat 1 files changed, 5 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log.c	Wed May 23 02:30:38 2007 +0300
+++ b/src/lib-index/mail-transaction-log.c	Wed May 23 19:07:12 2007 +0300
@@ -699,7 +699,7 @@
 }
 
 static void
-mail_transaction_log_file_add_to_head(struct mail_transaction_log_file *file)
+mail_transaction_log_file_add_to_list(struct mail_transaction_log_file *file)
 {
 	struct mail_transaction_log *log = file->log;
 	struct mail_transaction_log_file **p;
@@ -715,25 +715,11 @@
 		file->sync_offset = file->hdr.hdr_size;
 	}
 
-	/* append to end of list. */
-	for (p = &log->files; *p != NULL; p = &(*p)->next)
-		i_assert((*p)->hdr.file_seq < file->hdr.file_seq);
-	*p = file;
-}
-
-static void
-mail_transaction_log_file_add_to_list(struct mail_transaction_log_file *file)
-{
-	struct mail_transaction_log *log = file->log;
-	struct mail_transaction_log_file **p;
-
-	file->sync_offset = file->hdr.hdr_size;
-
 	/* insert it to correct position */
 	for (p = &log->files; *p != NULL; p = &(*p)->next) {
-		i_assert((*p)->hdr.file_seq != file->hdr.file_seq);
 		if ((*p)->hdr.file_seq > file->hdr.file_seq)
 			break;
+		i_assert((*p)->hdr.file_seq < file->hdr.file_seq);
 	}
 
 	file->next = *p;
@@ -791,7 +777,7 @@
 	if (ret < 0)
 		return errno == ENOENT && try_retry ? 0 : -1;
 
-        mail_transaction_log_file_add_to_head(file);
+        mail_transaction_log_file_add_to_list(file);
 	return 1;
 }
 
@@ -813,7 +799,7 @@
 	file->buffer = buffer_create_dynamic(default_pool, 4096);
 	file->buffer_offset = sizeof(file->hdr);
 
-	mail_transaction_log_file_add_to_head(file);
+	mail_transaction_log_file_add_to_list(file);
 	return file;
 }
 
@@ -881,7 +867,7 @@
                 		TRUE, i < MAIL_INDEX_ESTALE_RETRY_COUNT);
 		if (ret > 0) {
 			/* success */
-			mail_transaction_log_file_add_to_head(file);
+			mail_transaction_log_file_add_to_list(file);
 			return file;
 		}