dovecot-2.0: Transaction log view code cleanups.

dovecot at dovecot.org dovecot at dovecot.org
Sat May 9 19:32:19 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/08cf5c1814ef
changeset: 9251:08cf5c1814ef
user:      Timo Sirainen <tss at iki.fi>
date:      Sat May 09 12:32:04 2009 -0400
description:
Transaction log view code cleanups.

diffstat:

3 files changed, 44 insertions(+), 38 deletions(-)
src/lib-index/Makefile.am                         |    1 
src/lib-index/mail-transaction-log-view-private.h |   33 ++++++++++++++
src/lib-index/mail-transaction-log-view.c         |   48 ++++-----------------

diffs (146 lines):

diff -r 4d6f33fa08ee -r 08cf5c1814ef src/lib-index/Makefile.am
--- a/src/lib-index/Makefile.am	Sat May 09 12:29:08 2009 -0400
+++ b/src/lib-index/Makefile.am	Sat May 09 12:32:04 2009 -0400
@@ -47,6 +47,7 @@ headers = \
 	mail-index-view-private.h \
         mail-transaction-log.h \
 	mail-transaction-log-private.h \
+	mail-transaction-log-view-private.h \
         mailbox-list-index.h \
         mailbox-list-index-private.h
 
diff -r 4d6f33fa08ee -r 08cf5c1814ef src/lib-index/mail-transaction-log-view-private.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-index/mail-transaction-log-view-private.h	Sat May 09 12:32:04 2009 -0400
@@ -0,0 +1,33 @@
+#ifndef MAIL_TRANSACTION_LOG_VIEW_PRIVATE_H
+#define MAIL_TRANSACTION_LOG_VIEW_PRIVATE_H
+
+#include "mail-transaction-log-private.h"
+
+struct mail_transaction_log_view {
+	struct mail_transaction_log *log;
+        struct mail_transaction_log_view *next;
+
+	uint32_t min_file_seq, max_file_seq;
+	uoff_t min_file_offset, max_file_offset;
+
+	struct mail_transaction_header tmp_hdr;
+
+	/* a list of log files we've referenced. we have to keep this list
+	   explicitly because more files may be added into the linked list
+	   at any time. */
+	ARRAY_DEFINE(file_refs, struct mail_transaction_log_file *);
+        struct mail_transaction_log_file *cur, *head, *tail;
+	uoff_t cur_offset;
+
+	uint64_t prev_modseq;
+	uint32_t prev_file_seq;
+	uoff_t prev_file_offset;
+
+	struct mail_transaction_log_file *mark_file;
+	uoff_t mark_offset, mark_next_offset;
+	uint64_t mark_modseq;
+
+	unsigned int broken:1;
+};
+
+#endif
diff -r 4d6f33fa08ee -r 08cf5c1814ef src/lib-index/mail-transaction-log-view.c
--- a/src/lib-index/mail-transaction-log-view.c	Sat May 09 12:29:08 2009 -0400
+++ b/src/lib-index/mail-transaction-log-view.c	Sat May 09 12:32:04 2009 -0400
@@ -3,34 +3,7 @@
 #include "lib.h"
 #include "array.h"
 #include "mail-index-private.h"
-#include "mail-transaction-log-private.h"
-
-struct mail_transaction_log_view {
-	struct mail_transaction_log *log;
-        struct mail_transaction_log_view *next;
-
-	uint32_t min_file_seq, max_file_seq;
-	uoff_t min_file_offset, max_file_offset;
-
-	struct mail_transaction_header tmp_hdr;
-
-	/* a list of log files we've referenced. we have to keep this list
-	   explicitly because more files may be added into the linked list
-	   at any time. */
-	ARRAY_DEFINE(file_refs, struct mail_transaction_log_file *);
-        struct mail_transaction_log_file *cur, *head, *tail;
-	uoff_t cur_offset;
-
-	uint64_t prev_modseq;
-	uint32_t prev_file_seq;
-	uoff_t prev_file_offset;
-
-	struct mail_transaction_log_file *mark_file;
-	uoff_t mark_offset, mark_next_offset;
-	uint64_t mark_modseq;
-
-	unsigned int broken:1;
-};
+#include "mail-transaction-log-view-private.h"
 
 struct mail_transaction_log_view *
 mail_transaction_log_view_open(struct mail_transaction_log *log)
@@ -98,7 +71,7 @@ int mail_transaction_log_view_set(struct
 				  uint32_t max_file_seq, uoff_t max_file_offset,
 				  bool *reset_r)
 {
-	struct mail_transaction_log_file *file, *const *files;
+	struct mail_transaction_log_file *file, *const *files, *tail;
 	uoff_t start_offset, end_offset;
 	unsigned int i;
 	uint32_t seq;
@@ -114,15 +87,16 @@ int mail_transaction_log_view_set(struct
 		return -1;
 	}
 
+	tail = view->log->files;
 	if (min_file_seq == 0) {
 		/* index file doesn't exist yet. this transaction log should
 		   start from the beginning */
-		if (view->log->files->hdr.prev_file_seq != 0) {
+		if (tail->hdr.prev_file_seq != 0) {
 			/* but it doesn't */
 			return 0;
 		}
 
-		min_file_seq = view->log->files->hdr.file_seq;
+		min_file_seq = tail->hdr.file_seq;
 		min_file_offset = 0;
 
 		if (max_file_seq == 0) {
@@ -131,10 +105,10 @@ int mail_transaction_log_view_set(struct
 		}
 	} 
 
-	if (min_file_seq == view->log->files->hdr.prev_file_seq &&
-	    min_file_offset == view->log->files->hdr.prev_file_offset) {
+	if (min_file_seq == tail->hdr.prev_file_seq &&
+	    min_file_offset == tail->hdr.prev_file_offset) {
 		/* we can skip this */
-		min_file_seq = view->log->files->hdr.file_seq;
+		min_file_seq = tail->hdr.file_seq;
 		min_file_offset = 0;
 
 		if (min_file_seq > max_file_seq) {
@@ -153,14 +127,12 @@ int mail_transaction_log_view_set(struct
 		return -1;
 	}
 
-	if (min_file_offset > 0 &&
-	    min_file_offset < view->log->files->hdr.hdr_size) {
+	if (min_file_offset > 0 && min_file_offset < tail->hdr.hdr_size) {
 		/* log file offset is probably corrupted in the index file. */
 		mail_transaction_log_view_set_corrupted(view,
 			"file_seq=%u, min_file_offset (%"PRIuUOFF_T
 			") < hdr_size (%u)",
-			min_file_seq, min_file_offset,
-			view->log->files->hdr.hdr_size);
+			min_file_seq, min_file_offset, tail->hdr.hdr_size);
 		return -1;
 	}
 


More information about the dovecot-cvs mailing list