[dovecot-cvs] dovecot/src/lib-index mail-modifylog.c,1.28,1.29 mail-modifylog.h,1.4,1.5

cras at procontrol.fi cras at procontrol.fi
Wed Oct 23 21:03:41 EEST 2002


Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv19843/lib-index

Modified Files:
	mail-modifylog.c mail-modifylog.h 
Log Message:
Modify log was pretty much broken whenever it was switched.



Index: mail-modifylog.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-modifylog.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mail-modifylog.c	21 Oct 2002 01:56:20 -0000	1.28
+++ mail-modifylog.c	23 Oct 2002 17:03:39 -0000	1.29
@@ -9,21 +9,30 @@
 #include "mail-index-util.h"
 #include "mail-modifylog.h"
 
+#include <stddef.h>
 #include <stdlib.h>
 #include <fcntl.h>
 
 /* Maximum size for modify log (isn't exact) */
 #define MAX_MODIFYLOG_SIZE (4096*8)
 
+/* How large chunks to use to grow log file */
[...1503 lines suppressed...]
 	}
+
+	return expunges;
+}
+
+unsigned int mail_modifylog_get_expunge_count(MailModifyLog *log)
+{
+	unsigned int expunges;
+
+	i_assert(log->index->lock_type != MAIL_LOCK_UNLOCK);
+
+	if (!mmap_update_both(log))
+		return 0;
+
+	expunges = modifylog_file_get_expunge_count(log->tail);
+	if (log->tail != log->head)
+		expunges += modifylog_file_get_expunge_count(log->head);
 
 	return expunges;
 }

Index: mail-modifylog.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-modifylog.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mail-modifylog.h	19 Oct 2002 23:09:56 -0000	1.4
+++ mail-modifylog.h	23 Oct 2002 17:03:39 -0000	1.5
@@ -28,7 +28,7 @@
 
 /* for mail_modifylog_*_get_expunges() */
 struct _ModifyLogExpunge {
-	unsigned int uid1, uid2;
+	unsigned int uid1, uid2; /* NOTE: may be outside wanted range */
 	unsigned int seq_count;
 };
 
@@ -52,9 +52,13 @@
 /* Must be called when exclusive lock is dropped from index. */
 void mail_modifylog_notify_lock_drop(MailModifyLog *log);
 
-/* Returns the nonsynced log entries. count is set to number of log records. */
-ModifyLogRecord *mail_modifylog_get_nonsynced(MailModifyLog *log,
-					      unsigned int *count);
+/* Updates arr and count parameters to list nonsynced log entries.
+   Returns TRUE if successful. */
+int mail_modifylog_get_nonsynced(MailModifyLog *log,
+				 const ModifyLogRecord **arr1,
+				 unsigned int *count1,
+				 const ModifyLogRecord **arr2,
+				 unsigned int *count2);
 
 /* Marks the modify log as being synced with in-memory state. */
 int mail_modifylog_mark_synced(MailModifyLog *log);
@@ -63,16 +67,26 @@
    expunged messages before the range. Returns 0,0 terminated list of
    expunged UIDs, or NULL if error occured.
 
-   Note that the first and last returned records may contain more than the
-   wanted sequences, and expunges_before doesn't include those unwanted
-   expunges in the first record. */
+   Note that returned UID range may not be exact for first returned
+   expunge record. For example fetching range 9:10 may return
+   expunges_before=8, {uid1=1, uid2=9, seq_count=1} if only message 10
+   exists.
+
+   Also the last expunge record's both uid and seq_count ranges may go
+   past last_seq */
 const ModifyLogExpunge *
 mail_modifylog_seq_get_expunges(MailModifyLog *log,
 				unsigned int first_seq,
 				unsigned int last_seq,
 				unsigned int *expunges_before);
 
-/* Like above, but for given UID range. */
+/* Like above, but for given UID range. expunges_before is treated a bit
+   differently however. It specifies the number of messages deleted before
+   the first returned expunge-record, which may partially be before our
+   wanted range. For example fetching range 9:10 may return
+   expunges_before=0, {uid1=1, uid2=9, seq_count=9} if only message 10
+   exists. This is because we have no idea how many messages there are
+   between UIDs since they're not guaranteed to be contiguous. */
 const ModifyLogExpunge *
 mail_modifylog_uid_get_expunges(MailModifyLog *log,
 				unsigned int first_uid,




More information about the dovecot-cvs mailing list