[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-lock.c, 1.18, 1.19 mbox-storage.c, 1.121, 1.122

cras at dovecot.org cras at dovecot.org
Fri Sep 30 21:55:03 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv7270/lib-storage/index/mbox

Modified Files:
	mbox-lock.c mbox-storage.c 
Log Message:
Added MAILBOX_OPEN_NO_INDEX_FILES flag and made streamed mboxes by default
also indexed.



Index: mbox-lock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-lock.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mbox-lock.c	18 Sep 2005 16:43:45 -0000	1.18
+++ mbox-lock.c	30 Sep 2005 18:55:01 -0000	1.19
@@ -297,9 +297,6 @@
 			return -1;
 		}
 
-		if (max_wait_time == 0)
-			return 0;
-
 		now = time(NULL);
 		if (now >= max_wait_time)
 			return 0;
@@ -341,9 +338,6 @@
 			return -1;
 		}
 
-		if (max_wait_time == 0)
-			return 0;
-
 		now = time(NULL);
 		if (now >= max_wait_time)
 			return 0;
@@ -381,11 +375,16 @@
 	fl.l_start = 0;
 	fl.l_len = 0;
 
-	if (max_wait_time == 0)
+	if (max_wait_time == 0) {
+		i_assert(lock_type == F_UNLCK);
 		wait_type = F_SETLK;
-	else {
+	} else {
 		wait_type = F_SETLKW;
-		alarm(I_MIN(max_wait_time, 5));
+		now = time(NULL);
+		if (now >= max_wait_time)
+			alarm(1);
+		else
+			alarm(I_MIN(max_wait_time - now, 5));
 	}
 
 	while (fcntl(ctx->mbox->mbox_fd, wait_type, &fl) < 0) {
@@ -396,7 +395,7 @@
 		}
 
 		now = time(NULL);
-		if (max_wait_time != 0 && now >= max_wait_time) {
+		if (now >= max_wait_time) {
 			alarm(0);
 			return 0;
 		}

Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- mbox-storage.c	14 Aug 2005 21:54:26 -0000	1.121
+++ mbox-storage.c	30 Sep 2005 18:55:01 -0000	1.122
@@ -541,7 +541,13 @@
 		index_dir = mbox_get_index_dir(istorage, name);
 	}
 
-	index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX);
+	if ((flags & MAILBOX_OPEN_NO_INDEX_FILES) != 0)
+		index = mail_index_alloc(NULL, NULL);
+	else {
+		index = index_storage_alloc(index_dir, path,
+					    MBOX_INDEX_PREFIX);
+	}
+
 	mbox = mbox_alloc(storage, index, name, flags);
 	if (mbox == NULL)
 		return NULL;
@@ -564,12 +570,26 @@
 mbox_mailbox_open_stream(struct mbox_storage *storage, const char *name,
 			 struct istream *input, enum mailbox_open_flags flags)
 {
+	struct index_storage *istorage = INDEX_STORAGE(storage);
 	struct mail_index *index;
 	struct mbox_mailbox *mbox;
+	const char *path, *index_dir;
 
 	flags |= MAILBOX_OPEN_READONLY;
 
-	index = mail_index_alloc(NULL, NULL);
+	if ((flags & MAILBOX_OPEN_NO_INDEX_FILES) != 0)
+		index = mail_index_alloc(NULL, NULL);
+	else {
+		path = mbox_get_path(istorage, name);
+		index_dir = mbox_get_index_dir(istorage, name);
+
+		/* make sure the required directories are also there */
+		if (create_mbox_index_dirs(istorage, name) < 0)
+			return NULL;
+
+		index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX);
+	}
+
 	mbox = mbox_alloc(storage, index, name, flags);
 	if (mbox == NULL)
 		return NULL;



More information about the dovecot-cvs mailing list