dovecot-2.0: sdbox: Avoid logging multiple adjacent "Invalid dbo...

dovecot at dovecot.org dovecot at dovecot.org
Sun Apr 4 23:12:03 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/d16bfa082e88
changeset: 11024:d16bfa082e88
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Apr 04 23:01:23 2010 +0300
description:
sdbox: Avoid logging multiple adjacent "Invalid dbox header size" errors.

diffstat:

 src/lib-storage/index/dbox-single/sdbox-storage.c      |  17 ++++++++++-------
 src/lib-storage/index/dbox-single/sdbox-storage.h      |   2 +-
 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c |   2 +-
 src/lib-storage/index/dbox-single/sdbox-sync.c         |  13 +++++++------
 4 files changed, 19 insertions(+), 15 deletions(-)

diffs (126 lines):

diff -r 46ede677961d -r d16bfa082e88 src/lib-storage/index/dbox-single/sdbox-storage.c
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c	Sun Apr 04 22:24:43 2010 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c	Sun Apr 04 23:01:23 2010 +0300
@@ -64,7 +64,7 @@
 }
 
 int sdbox_read_header(struct sdbox_mailbox *mbox,
-		      struct sdbox_index_header *hdr)
+		      struct sdbox_index_header *hdr, bool log_error)
 {
 	const void *data;
 	size_t data_size;
@@ -73,9 +73,12 @@
 				  &data, &data_size);
 	if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
 	    (!mbox->creating || data_size != 0)) {
-		mail_storage_set_critical(&mbox->storage->storage.storage,
-			"dbox %s: Invalid dbox header size",
-			mbox->box.path);
+		if (log_error) {
+			mail_storage_set_critical(
+				&mbox->storage->storage.storage,
+				"dbox %s: Invalid dbox header size",
+				mbox->box.path);
+		}
 		return -1;
 	}
 	memset(hdr, 0, sizeof(*hdr));
@@ -89,7 +92,7 @@
 {
 	struct sdbox_index_header hdr, new_hdr;
 
-	if (sdbox_read_header(mbox, &hdr) < 0)
+	if (sdbox_read_header(mbox, &hdr, TRUE) < 0)
 		memset(&hdr, 0, sizeof(hdr));
 
 	new_hdr = hdr;
@@ -176,13 +179,13 @@
 	struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)box;
 	struct sdbox_index_header hdr;
 
-	if (sdbox_read_header(mbox, &hdr) < 0)
+	if (sdbox_read_header(mbox, &hdr, TRUE) < 0)
 		memset(&hdr, 0, sizeof(hdr));
 
 	if (mail_guid_128_is_empty(hdr.mailbox_guid)) {
 		/* regenerate it */
 		if (sdbox_write_index_header(box, NULL) < 0 ||
-		    sdbox_read_header(mbox, &hdr) < 0)
+		    sdbox_read_header(mbox, &hdr, TRUE) < 0)
 			return -1;
 	}
 	memcpy(guid, hdr.mailbox_guid, MAIL_GUID_128_SIZE);
diff -r 46ede677961d -r d16bfa082e88 src/lib-storage/index/dbox-single/sdbox-storage.h
--- a/src/lib-storage/index/dbox-single/sdbox-storage.h	Sun Apr 04 22:24:43 2010 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.h	Sun Apr 04 23:01:23 2010 +0300
@@ -40,7 +40,7 @@
 
 uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list);
 int sdbox_read_header(struct sdbox_mailbox *mbox,
-		      struct sdbox_index_header *hdr);
+		      struct sdbox_index_header *hdr, bool log_error);
 void sdbox_update_header(struct sdbox_mailbox *mbox,
 			 struct mail_index_transaction *trans,
 			 const struct mailbox_update *update);
diff -r 46ede677961d -r d16bfa082e88 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c	Sun Apr 04 22:24:43 2010 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c	Sun Apr 04 23:01:23 2010 +0300
@@ -130,7 +130,7 @@
 	struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->box;
 	struct sdbox_index_header hdr;
 
-	if (sdbox_read_header(mbox, &hdr) < 0)
+	if (sdbox_read_header(mbox, &hdr, FALSE) < 0)
 		memset(&hdr, 0, sizeof(hdr));
 	if (!mail_guid_128_is_empty(hdr.mailbox_guid))
 		mail_generate_guid_128(hdr.mailbox_guid);
diff -r 46ede677961d -r d16bfa082e88 src/lib-storage/index/dbox-single/sdbox-sync.c
--- a/src/lib-storage/index/dbox-single/sdbox-sync.c	Sun Apr 04 22:24:43 2010 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-sync.c	Sun Apr 04 23:01:23 2010 +0300
@@ -142,21 +142,22 @@
 	return ret;
 }
 
-static int sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry)
+static int
+sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry, bool log_error)
 {
 	struct mail_index_view *view;
 	struct sdbox_index_header hdr;
 	int ret;
 
 	view = mail_index_view_open(mbox->box.index);
-	ret = sdbox_read_header(mbox, &hdr);
+	ret = sdbox_read_header(mbox, &hdr, log_error);
 	mail_index_view_close(&view);
 
 	if (ret == 0) {
 		ret = mbox->sync_rebuild ? -1 : 0;
 	} else if (retry) {
 		(void)mail_index_refresh(mbox->box.index);
-		return sdbox_refresh_header(mbox, FALSE);
+		return sdbox_refresh_header(mbox, FALSE, log_error);
 	}
 	return ret;
 }
@@ -171,7 +172,7 @@
 	int ret;
 	bool rebuild;
 
-	rebuild = sdbox_refresh_header(mbox, TRUE) < 0 ||
+	rebuild = sdbox_refresh_header(mbox, TRUE, FALSE) < 0 ||
 		(flags & SDBOX_SYNC_FLAG_FORCE_REBUILD) != 0;
 
 	ctx = i_new(struct sdbox_sync_context, 1);
@@ -199,8 +200,8 @@
 			return ret;
 		}
 
-		/* now that we're locked, check again if we want to rebuild */
-		if (sdbox_refresh_header(mbox, FALSE) < 0)
+		/* now that we're locked, check again if we want to rebuild. */
+		if (sdbox_refresh_header(mbox, FALSE, TRUE) < 0)
 			ret = 0;
 		else {
 			if ((ret = sdbox_sync_index(ctx)) > 0)


More information about the dovecot-cvs mailing list