[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-storage.c, 1.30, 1.31 dbox-storage.h, 1.15, 1.16 dbox-sync-expunge.c, 1.21, 1.22 dbox-uidlist.c, 1.42, 1.43

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


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

Modified Files:
	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.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- dbox-storage.c	21 Dec 2006 15:20:31 -0000	1.30
+++ dbox-storage.c	28 Dec 2006 16:51:10 -0000	1.31
@@ -17,6 +17,45 @@
 
 #define CREATE_MODE 0770 /* umask() should limit it more */
 
+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;
 
@@ -125,6 +164,15 @@
 		return NULL;
 	}
 
+	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.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dbox-storage.h	16 Nov 2006 00:16:33 -0000	1.15
+++ dbox-storage.h	28 Dec 2006 16:51:11 -0000	1.16
@@ -14,6 +14,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.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dbox-sync-expunge.c	10 Sep 2006 12:48:26 -0000	1.21
+++ dbox-sync-expunge.c	28 Dec 2006 16:51:12 -0000	1.22
@@ -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;
 		}
@@ -172,7 +161,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);
@@ -196,14 +185,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);
@@ -251,9 +240,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;
 		}
 	}
@@ -484,8 +472,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.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- dbox-uidlist.c	17 Dec 2006 16:35:33 -0000	1.42
+++ dbox-uidlist.c	28 Dec 2006 16:51:12 -0000	1.43
@@ -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)
@@ -451,19 +425,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;
 	}
@@ -1069,7 +1045,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