[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-storage.c, 1.15.2.7, 1.15.2.8 dbox-storage.h, 1.10.2.1, 1.10.2.2 dbox-sync-expunge.c, 1.15.2.3, 1.15.2.4 dbox-uidlist.c, 1.28.2.11, 1.28.2.12

tss at dovecot.org tss at dovecot.org
Thu Dec 28 16:51:09 UTC 2006


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

Modified Files:
      Tag: branch_1_0
	dbox-storage.c dbox-storage.h dbox-sync-expunge.c 
	dbox-uidlist.c 
Log Message:
More dotlock_use_excl uses.



Index: dbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.c,v
retrieving revision 1.15.2.7
retrieving revision 1.15.2.8
diff -u -d -r1.15.2.7 -r1.15.2.8
--- dbox-storage.c	3 Dec 2006 13:29:54 -0000	1.15.2.7
+++ dbox-storage.c	28 Dec 2006 16:51:06 -0000	1.15.2.8
@@ -23,6 +23,45 @@
    problems when they reach the limit. */
 #define DBOX_MAX_MAILBOX_NAME_LENGTH (PATH_MAX/2)
 
+const struct dotlock_settings default_uidlist_dotlock_set = {
+	MEMBER(temp_prefix) NULL,
+	MEMBER(lock_suffix) NULL,
+
+	MEMBER(timeout) 120,
+	MEMBER(stale_timeout) 60,
+
+	MEMBER(callback) NULL,
+	MEMBER(context) NULL,
+
+	MEMBER(use_excl_lock) FALSE
+};
+
+const struct dotlock_settings default_file_dotlock_set = {
+	MEMBER(temp_prefix) NULL,
+	MEMBER(lock_suffix) NULL,
+
+	MEMBER(timeout) 120,
+	MEMBER(stale_timeout) 60,
+
+	MEMBER(callback) NULL,
+	MEMBER(context) NULL,
+
+	MEMBER(use_excl_lock) FALSE
+};
+
+static const struct dotlock_settings default_new_file_dotlock_set = {
+	MEMBER(temp_prefix) NULL,
+	MEMBER(lock_suffix) NULL,
+
+	MEMBER(timeout) 60,
+	MEMBER(stale_timeout) 30,
+
+	MEMBER(callback) NULL,
+	MEMBER(context) NULL,
+
+	MEMBER(use_excl_lock) FALSE
+};
+
 extern struct mail_storage dbox_storage;
 extern struct mailbox dbox_mailbox;
 
@@ -112,6 +151,15 @@
 	pool = pool_alloconly_create("storage", 512);
 	storage = p_new(pool, struct dbox_storage, 1);
 
+	storage->uidlist_dotlock_set = default_uidlist_dotlock_set;
+	storage->file_dotlock_set = default_file_dotlock_set;
+	storage->new_file_dotlock_set = default_new_file_dotlock_set;
+	if ((flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0) {
+		storage->uidlist_dotlock_set.use_excl_lock = TRUE;
+		storage->file_dotlock_set.use_excl_lock = TRUE;
+		storage->new_file_dotlock_set.use_excl_lock = TRUE;
+	}
+
 	istorage = INDEX_STORAGE(storage);
 	istorage->storage = dbox_storage;
 	istorage->storage.pool = pool;

Index: dbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.h,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -d -r1.10.2.1 -r1.10.2.2
--- dbox-storage.h	12 Jun 2006 08:24:03 -0000	1.10.2.1
+++ dbox-storage.h	28 Dec 2006 16:51:06 -0000	1.10.2.2
@@ -13,6 +13,10 @@
 
 struct dbox_storage {
 	struct index_storage storage;
+
+	struct dotlock_settings uidlist_dotlock_set;
+	struct dotlock_settings file_dotlock_set;
+	struct dotlock_settings new_file_dotlock_set;
 };
 
 struct keyword_map {

Index: dbox-sync-expunge.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-expunge.c,v
retrieving revision 1.15.2.3
retrieving revision 1.15.2.4
diff -u -d -r1.15.2.3 -r1.15.2.4
--- dbox-sync-expunge.c	23 Jul 2006 19:08:56 -0000	1.15.2.3
+++ dbox-sync-expunge.c	28 Dec 2006 16:51:06 -0000	1.15.2.4
@@ -14,19 +14,6 @@
 
 #include <stddef.h>
 
-static const struct dotlock_settings new_file_dotlock_set = {
-	MEMBER(temp_prefix) NULL,
-	MEMBER(lock_suffix) NULL,
-
-	MEMBER(timeout) 60,
-	MEMBER(stale_timeout) 30,
-
-	MEMBER(callback) NULL,
-	MEMBER(context) NULL,
-
-	MEMBER(use_excl_lock) FALSE
-};
-
 static int
 dbox_sync_rec_get_uids(struct dbox_sync_context *ctx,
 		       const struct dbox_sync_rec *sync_rec,
@@ -77,6 +64,7 @@
 				  uoff_t orig_offset)
 {
 	struct dbox_mailbox *mbox = ctx->mbox;
+	struct mail_storage *storage = STORAGE(mbox->storage);
 	struct dotlock *dotlock;
 	struct istream *input;
 	struct ostream *output;
@@ -108,7 +96,7 @@
 
 	if (ret <= 0) {
 		if (ret == 0) {
-			mail_storage_set_critical(STORAGE(mbox->storage),
+			mail_storage_set_critical(storage,
 				"%s: Expunging lost UID %u from file %u",
 				mbox->path, first_nonexpunged_uid,
 				orig_entry->file_seq);
@@ -131,13 +119,14 @@
 		path = t_strdup_printf("%s/"DBOX_MAILDIR_NAME"/"
 				       DBOX_MAIL_FILE_FORMAT,
 				       mbox->path, file_seq);
-		fd = file_dotlock_open(&new_file_dotlock_set, path,
-				       DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock);
+		fd = file_dotlock_open(&mbox->storage->new_file_dotlock_set,
+				       path, DOTLOCK_CREATE_FLAG_NONBLOCK,
+				       &dotlock);
 		if (fd >= 0)
 			break;
 
 		if (errno != EAGAIN) {
-			mail_storage_set_critical(STORAGE(mbox->storage),
+			mail_storage_set_critical(storage,
 				"file_dotlock_open(%s) failed: %m", path);
 			return -1;
 		}
@@ -173,7 +162,7 @@
 		}
 
 		if (seq == 0) {
-			mail_storage_set_critical(STORAGE(mbox->storage),
+			mail_storage_set_critical(storage,
 				"Expunged UID %u reappeared in file %s",
 				uid, path);
 			mail_index_mark_corrupted(mbox->ibox.index);
@@ -197,14 +186,14 @@
 		i_stream_destroy(&input);
 
 		if (bytes < 0) {
-			mail_storage_set_critical(STORAGE(mbox->storage),
+			mail_storage_set_critical(storage,
 				"o_stream_send_istream(%s) failed: %m",
 				lock_path);
 			ret = -1;
 			break;
 		}
 		if ((uoff_t)bytes != full_size) {
-			mail_storage_set_critical(STORAGE(mbox->storage),
+			mail_storage_set_critical(storage,
 				"o_stream_send_istream(%s) wrote only %"
 				PRIuUOFF_T" of %"PRIuUOFF_T" bytes", lock_path,
 				(uoff_t)bytes, full_size);
@@ -252,9 +241,8 @@
 				sizeof(hdr.append_offset_hex),
 				offsetof(struct dbox_file_header,
 					 append_offset_hex)) < 0) {
-			mail_storage_set_critical(STORAGE(mbox->storage),
-						  "pwrite_full(%s) failed: %m",
-						  lock_path);
+			mail_storage_set_critical(storage,
+				"pwrite_full(%s) failed: %m", lock_path);
 			ret = -1;
 		}
 	}
@@ -485,8 +473,8 @@
 		path = t_strdup_printf("%s/"DBOX_MAILDIR_NAME"/"
 				       DBOX_MAIL_FILE_FORMAT,
 				       mbox->path, sync_entry->file_seq);
-		ret = file_dotlock_create(&new_file_dotlock_set, path,
-					  DOTLOCK_CREATE_FLAG_NONBLOCK,
+		ret = file_dotlock_create(&mbox->storage->new_file_dotlock_set,
+					  path, DOTLOCK_CREATE_FLAG_NONBLOCK,
 					  &dotlock);
 		if (ret < 0) {
 			mail_storage_set_critical(STORAGE(mbox->storage),

Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.28.2.11
retrieving revision 1.28.2.12
diff -u -d -r1.28.2.11 -r1.28.2.12
--- dbox-uidlist.c	12 Nov 2006 20:04:18 -0000	1.28.2.11
+++ dbox-uidlist.c	28 Dec 2006 16:51:06 -0000	1.28.2.12
@@ -80,32 +80,6 @@
 	unsigned int modified:1;
 };
 
-const struct dotlock_settings uidlist_dotlock_settings = {
-	MEMBER(temp_prefix) NULL,
-	MEMBER(lock_suffix) NULL,
-
-	MEMBER(timeout) 120,
-	MEMBER(stale_timeout) 60,
-
-	MEMBER(callback) NULL,
-	MEMBER(context) NULL,
-
-	MEMBER(use_excl_lock) FALSE
-};
-
-const struct dotlock_settings dbox_file_dotlock_set = {
-	MEMBER(temp_prefix) NULL,
-	MEMBER(lock_suffix) NULL,
-
-	MEMBER(timeout) 120,
-	MEMBER(stale_timeout) 60,
-
-	MEMBER(callback) NULL,
-	MEMBER(context) NULL,
-
-	MEMBER(use_excl_lock) FALSE
-};
-
 static int dbox_uidlist_full_rewrite(struct dbox_uidlist *uidlist);
 
 struct dbox_uidlist *dbox_uidlist_init(struct dbox_mailbox *mbox)
@@ -454,19 +428,21 @@
 
 int dbox_uidlist_lock(struct dbox_uidlist *uidlist)
 {
+	struct dbox_mailbox *mbox = uidlist->mbox;
+
 	if (uidlist->lock_count == 0)
 		i_assert(uidlist->lock_fd == -1);
 	else {
-		i_assert(uidlist->mbox->ibox.keep_locked);
+		i_assert(mbox->ibox.keep_locked);
 		uidlist->lock_count++;
 		return 0;
 	}
 
-	uidlist->lock_fd = file_dotlock_open(&uidlist_dotlock_settings,
-					     uidlist->path, 0,
-					     &uidlist->dotlock);
+	uidlist->lock_fd =
+		file_dotlock_open(&mbox->storage->uidlist_dotlock_set,
+				  uidlist->path, 0, &uidlist->dotlock);
 	if (uidlist->lock_fd == -1) {
-		mail_storage_set_critical(STORAGE(uidlist->mbox->storage),
+		mail_storage_set_critical(STORAGE(mbox->storage),
 			"file_dotlock_open(%s) failed: %m", uidlist->path);
 		return -1;
 	}
@@ -1062,7 +1038,8 @@
 		str_truncate(path, 0);
 		str_printfa(path, "%s/"DBOX_MAILDIR_NAME"/"
 			    DBOX_MAIL_FILE_FORMAT, mbox->path, file_seq);
-		ret = file_dotlock_create(&dbox_file_dotlock_set, str_c(path),
+		ret = file_dotlock_create(&mbox->storage->file_dotlock_set,
+					  str_c(path),
 					  DOTLOCK_CREATE_FLAG_NONBLOCK,
 					  dotlock_r);
 		if (ret > 0) {



More information about the dovecot-cvs mailing list