[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c,1.47,1.48

cras at procontrol.fi cras at procontrol.fi
Wed Jul 23 06:55:14 EEST 2003


Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory danu:/tmp/cvs-serv11704/lib-storage/index/maildir

Modified Files:
	maildir-storage.c 
Log Message:
Explicit lock() method for mailbox.



Index: maildir-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- maildir-storage.c	23 Jul 2003 01:44:16 -0000	1.47
+++ maildir-storage.c	23 Jul 2003 02:55:12 -0000	1.48
@@ -705,6 +705,31 @@
 	}
 }
 
+static int maildir_storage_lock(struct mailbox *box,
+				enum mailbox_lock_type lock_type)
+{
+	struct index_mailbox *ibox = (struct index_mailbox *) box;
+
+	if (lock_type == MAIL_LOCK_UNLOCK) {
+		ibox->lock_type = MAIL_LOCK_UNLOCK;
+		if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+			return FALSE;
+		return TRUE;
+	}
+
+	i_assert(ibox->lock_type == MAIL_LOCK_UNLOCK);
+
+	if ((lock_type & (MAILBOX_LOCK_EXPUNGE | MAILBOX_LOCK_FLAGS)) != 0) {
+		if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
+			return FALSE;
+	} else if ((lock_type & MAILBOX_LOCK_READ) != 0) {
+		if (!index_storage_lock(ibox, MAIL_LOCK_SHARED))
+			return FALSE;
+	}
+
+	ibox->lock_type = lock_type;
+	return TRUE;
+}
 
 struct mail_storage maildir_storage = {
 	"maildir", /* name */
@@ -741,6 +766,7 @@
 	NULL, /* storage */
 
 	maildir_storage_close,
+	maildir_storage_lock,
 	index_storage_get_status,
 	index_storage_sync,
 	maildir_storage_auto_sync,



More information about the dovecot-cvs mailing list