[dovecot-cvs] dovecot/src/lib-storage/index index-search.c, 1.83, 1.84 index-status.c, 1.27, 1.28 index-storage.c, 1.42, 1.43

cras at procontrol.fi cras at procontrol.fi
Wed Apr 28 03:21:03 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv32334/lib-storage/index

Modified Files:
	index-search.c index-status.c index-storage.c 
Log Message:
Forced locking to be right with mprotect()ing index file. Support for
disabling mmap for indexes, and disabling just mmap+write().



Index: index-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- index-search.c	27 Apr 2004 20:25:54 -0000	1.83
+++ index-search.c	28 Apr 2004 00:21:01 -0000	1.84
@@ -558,17 +558,16 @@
 }
 
 static int search_parse_msgset_args(struct index_mailbox *ibox,
+				    const struct mail_index_header *hdr,
 				    struct mail_search_arg *args,
 				    uint32_t *seq1_r, uint32_t *seq2_r)
 {
-	const struct mail_index_header *hdr;
-
 	*seq1_r = *seq2_r = 0;
 
-	hdr = mail_index_get_header(ibox->view);
 	for (; args != NULL; args = args->next) {
 		if (args->type == SEARCH_SUB) {
-			if (search_parse_msgset_args(ibox, args->value.subargs,
+			if (search_parse_msgset_args(ibox, hdr,
+						     args->value.subargs,
 						     seq1_r, seq2_r) < 0)
 				return -1;
 		} else if (args->type == SEARCH_OR) {
@@ -581,7 +580,8 @@
 			*seq2_r = hdr->messages_count;
 
                         /* We still have to fix potential seqsets though */
-			if (search_parse_msgset_args(ibox, args->value.subargs,
+			if (search_parse_msgset_args(ibox, hdr,
+						     args->value.subargs,
 						     seq1_r, seq2_r) < 0)
 				return -1;
 		} else if (args->type == SEARCH_SEQSET) {
@@ -601,15 +601,12 @@
 static int search_limit_lowwater(struct index_mailbox *ibox,
 				 uint32_t uid_lowwater, uint32_t *first_seq)
 {
-        const struct mail_index_header *hdr;
 	uint32_t seq1, seq2;
 
 	if (uid_lowwater == 0)
 		return 0;
 
-	hdr = mail_index_get_header(ibox->view);
-	if (mail_index_lookup_uid_range(ibox->view, uid_lowwater,
-					hdr->next_uid-1,
+	if (mail_index_lookup_uid_range(ibox->view, uid_lowwater, (uint32_t)-1,
 					&seq1, &seq2) < 0) {
 		mail_storage_set_index_error(ibox);
 		return -1;
@@ -621,12 +618,10 @@
 }
 
 static int search_limit_by_flags(struct index_mailbox *ibox,
+                                 const struct mail_index_header *hdr,
 				 struct mail_search_arg *args,
 				 uint32_t *seq1, uint32_t *seq2)
 {
-	const struct mail_index_header *hdr;
-
-	hdr = mail_index_get_header(ibox->view);
 	for (; args != NULL; args = args->next) {
 		if (args->type == SEARCH_SEEN) {
 			/* SEEN with 0 seen? */
@@ -688,12 +683,16 @@
 {
         const struct mail_index_header *hdr;
 
-	if (search_parse_msgset_args(ctx->ibox, args,
+	if (mail_index_get_header(ctx->ibox->view, &hdr) < 0) {
+		mail_storage_set_index_error(ctx->ibox);
+		return -1;
+	}
+
+	if (search_parse_msgset_args(ctx->ibox, hdr, args,
 				     &ctx->seq1, &ctx->seq2) < 0)
 		return -1;
 
 	if (ctx->seq1 == 0) {
-		hdr = mail_index_get_header(ctx->ibox->view);
 		ctx->seq1 = 1;
 		ctx->seq2 = hdr->messages_count;
 	}
@@ -701,7 +700,8 @@
 	i_assert(ctx->seq1 <= ctx->seq2);
 
 	/* UNSEEN and DELETED in root search level may limit the range */
-	if (search_limit_by_flags(ctx->ibox, args, &ctx->seq1, &ctx->seq2) < 0)
+	if (search_limit_by_flags(ctx->ibox, hdr, args,
+				  &ctx->seq1, &ctx->seq2) < 0)
 		return -1;
 	return 0;
 }

Index: index-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-status.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- index-status.c	27 Apr 2004 20:25:54 -0000	1.27
+++ index-status.c	28 Apr 2004 00:21:01 -0000	1.28
@@ -37,7 +37,8 @@
 	}
 
 	/* we can get most of the status items without any trouble */
-	hdr = mail_index_get_header(ibox->view);
+	if (mail_index_get_header(ibox->view, &hdr) < 0)
+		return -1;
 	if ((items & STATUS_MESSAGE_COUNTS) != 0) {
 		status->messages = hdr->messages_count;
 		status->unseen = hdr->messages_count - hdr->seen_messages_count;

Index: index-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- index-storage.c	27 Apr 2004 20:25:54 -0000	1.42
+++ index-storage.c	28 Apr 2004 00:21:01 -0000	1.43
@@ -312,6 +312,10 @@
 	index_flags = MAIL_INDEX_OPEN_FLAG_CREATE;
 	if ((flags & MAILBOX_OPEN_FAST) != 0)
 		index_flags |= MAIL_INDEX_OPEN_FLAG_FAST;
+	if (getenv("MMAP_DISABLE") != NULL)
+		index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE;
+	if (getenv("MMAP_NO_WRITE") != NULL)
+		index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE;
 
 	do {
 		ibox = i_new(struct index_mailbox, 1);



More information about the dovecot-cvs mailing list