[PATCH 08/13] Syslog about changes to mailbox stats when reconstructing

Bron Gondwana brong at fastmail.fm
Tue Jan 27 23:15:35 EST 2009


From: Bron Gondwana <brong at launde.home.brong.net>

This will help with debugging quota changes, but also
finding out anything else odd that's going on in the
mailboxes.  In _theory_ it should always print nothing
if stuff hasn't broken.
---
 imap/reconstruct.c |   41 +++++++++++++++++++++++++++++++++--------
 1 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/imap/reconstruct.c b/imap/reconstruct.c
index 83833b4..f6b8aaa 100644
--- a/imap/reconstruct.c
+++ b/imap/reconstruct.c
@@ -903,7 +903,7 @@ int reconstruct(char *name, struct discovered *found)
 	mailbox.exists = 0;
 	mailbox.last_uid = 0;
 	mailbox.last_appenddate = 0;
-	mailbox.uidvalidity = time(0);
+	mailbox.uidvalidity = now;
 	/* If we can't read the index, assume new UIDL so that stupid clients
 	   will retrieve all of the messages in the mailbox. */
 	mailbox.options = OPT_POP3_NEW_UIDL;
@@ -1127,8 +1127,8 @@ int reconstruct(char *name, struct discovered *found)
             message_index.modseq = 1;
         }
 
-        if (message_index.modseq > mailbox.highestmodseq) {
-            mailbox.highestmodseq = message_index.modseq;
+        if (message_index.modseq > highestmodseq) {
+            highestmodseq = message_index.modseq;
         }
 
 	/* Force rebuild from message_create_record() */
@@ -1166,12 +1166,37 @@ int reconstruct(char *name, struct discovered *found)
     }
 
     /* Write out new index and expunge file headers */
-    if (uid_num && mailbox.last_uid < uid[uid_num-1])
+    if (uid_num && mailbox.last_uid < uid[uid_num-1]) {
+	syslog (LOG_ERR, "Updating last_uid for %s: %lu => %lu",
+		mailbox.name, mailbox.last_uid, uid[uid_num-1] + 100);
 	mailbox.last_uid = uid[uid_num-1] + 100;
-    if (mailbox.last_appenddate == 0 || mailbox.last_appenddate > time(0))
-	mailbox.last_appenddate = time(0);
-    if (mailbox.uidvalidity == 0 || mailbox.uidvalidity > (unsigned) time(0))
-	mailbox.uidvalidity = time(0);
+    }
+
+    if (mailbox.last_appenddate == 0 || mailbox.last_appenddate > now) {
+	syslog (LOG_ERR, "Updating last_appenddate for %s: %lu => %lu",
+		mailbox.name, mailbox.last_appenddate, now);
+	mailbox.last_appenddate = now;
+    }
+
+    if (mailbox.uidvalidity == 0 || mailbox.uidvalidity > (unsigned)now) {
+	syslog (LOG_ERR, "Updating uidvalidity for %s: %lu => %lu",
+		mailbox.name, mailbox.uidvalidity, now);
+	mailbox.uidvalidity = (unsigned)now;
+    }
+
+    if (mailbox.highestmodseq < highestmodseq) {
+	syslog (LOG_ERR, "Updating highestmodseq for %s: %lu => %lu",
+		mailbox.name, (unsigned long)mailbox.highestmodseq, 
+		(unsigned long)highestmodseq);
+	mailbox.highestmodseq = highestmodseq;
+    }
+
+    if (mailbox.quota_mailbox_used != index_counts.newquota_used) {
+	syslog (LOG_ERR, "Updating quota_mailbox_used for %s: %lu => %lu",
+		mailbox.name, (unsigned long)mailbox.quota_mailbox_used, 
+		(unsigned long)index_counts.newquota_used);
+	/* updated by the counts_tobuf below, different in each file */
+    }
 
     rewind(newindex);
     reconstruct_counts_tobuf(buf, &mailbox, &index_counts);
-- 
1.5.6.3



More information about the Cyrus-devel mailing list