[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-storage.c, 1.20, 1.21 dbox-uidlist.c, 1.33, 1.34 dbox-uidlist.h, 1.7, 1.8

cras at dovecot.org cras at dovecot.org
Sun Jul 23 17:21:03 EEST 2006


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

Modified Files:
	dbox-storage.c dbox-uidlist.c dbox-uidlist.h 
Log Message:
Make pop3_lock_session work with dbox.



Index: dbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- dbox-storage.c	28 Jun 2006 16:31:07 -0000	1.20
+++ dbox-storage.c	23 Jul 2006 14:20:59 -0000	1.21
@@ -379,6 +379,14 @@
 					sizeof(uint64_t), sizeof(uint64_t));
 
 	mbox->uidlist = dbox_uidlist_init(mbox);
+	if (mbox->ibox.keep_locked) {
+		if (dbox_uidlist_lock(mbox->uidlist) < 0) {
+			struct mailbox *box = &mbox->ibox.box;
+
+			mailbox_close(&box);
+			return NULL;
+		}
+	}
 	return &mbox->ibox.box;
 }
 
@@ -641,6 +649,8 @@
 {
 	struct dbox_mailbox *mbox = (struct dbox_mailbox *)box;
 
+	if (mbox->ibox.keep_locked)
+		dbox_uidlist_unlock(mbox->uidlist);
 	dbox_uidlist_deinit(mbox->uidlist);
 	if (mbox->file != NULL)
 		dbox_file_close(mbox->file);

Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- dbox-uidlist.c	28 Jun 2006 13:10:50 -0000	1.33
+++ dbox-uidlist.c	23 Jul 2006 14:20:59 -0000	1.34
@@ -44,6 +44,7 @@
 
 	struct dotlock *dotlock;
 	int lock_fd;
+	unsigned int lock_count;
 
 	unsigned int version;
 	uint32_t uid_validity, last_uid, last_file_seq;
@@ -442,9 +443,15 @@
 	return ret;
 }
 
-static int dbox_uidlist_lock(struct dbox_uidlist *uidlist)
+int dbox_uidlist_lock(struct dbox_uidlist *uidlist)
 {
-	i_assert(uidlist->lock_fd == -1);
+	if (uidlist->lock_count == 0)
+		i_assert(uidlist->lock_fd == -1);
+	else {
+		i_assert(uidlist->mbox->ibox.keep_locked);
+		uidlist->lock_count++;
+		return 0;
+	}
 
 	uidlist->lock_fd = file_dotlock_open(&uidlist_dotlock_settings,
 					     uidlist->path, 0,
@@ -455,13 +462,19 @@
 		return -1;
 	}
 
+	uidlist->lock_count++;
 	return 0;
 }
 
-static void dbox_uidlist_unlock(struct dbox_uidlist *uidlist)
+void dbox_uidlist_unlock(struct dbox_uidlist *uidlist)
 {
 	i_assert(uidlist->lock_fd != -1);
 
+	if (--uidlist->lock_count > 0) {
+		i_assert(uidlist->mbox->ibox.keep_locked);
+		return;
+	}
+
 	(void)file_dotlock_delete(&uidlist->dotlock);
 	uidlist->lock_fd = -1;
 }

Index: dbox-uidlist.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbox-uidlist.h	28 Jun 2006 13:10:51 -0000	1.7
+++ dbox-uidlist.h	23 Jul 2006 14:20:59 -0000	1.8
@@ -20,6 +20,9 @@
 struct dbox_uidlist *dbox_uidlist_init(struct dbox_mailbox *mbox);
 void dbox_uidlist_deinit(struct dbox_uidlist *uidlist);
 
+int dbox_uidlist_lock(struct dbox_uidlist *uidlist);
+void dbox_uidlist_unlock(struct dbox_uidlist *uidlist);
+
 struct dbox_uidlist_entry *
 dbox_uidlist_entry_lookup(struct dbox_uidlist *uidlist, uint32_t file_seq);
 



More information about the dovecot-cvs mailing list