[dovecot-cvs]
dovecot/src/lib-storage/index/mbox mbox-storage.c,1.59,1.60
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/mbox
In directory danu:/tmp/cvs-serv11704/lib-storage/index/mbox
Modified Files:
mbox-storage.c
Log Message:
Explicit lock() method for mailbox.
Index: mbox-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- mbox-storage.c 23 Jul 2003 01:44:16 -0000 1.59
+++ mbox-storage.c 23 Jul 2003 02:55:12 -0000 1.60
@@ -708,6 +708,39 @@
index_mailbox_check_add(ibox, ibox->index->mailbox_path);
}
+static int mbox_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;
+ }
+
+ if ((lock_type & (MAILBOX_LOCK_EXPUNGE | MAILBOX_LOCK_SAVE)) != 0) {
+ /* FIXME: saving doesn't have to sync it, just lock it */
+ if (!index_storage_sync_and_lock(ibox, FALSE, TRUE,
+ MAIL_LOCK_EXCLUSIVE))
+ return FALSE;
+ }
+
+ ibox->lock_type = lock_type;
+ return TRUE;
+}
+
struct mail_storage mbox_storage = {
"mbox", /* name */
@@ -743,6 +776,7 @@
NULL, /* storage */
mbox_storage_close,
+ mbox_storage_lock,
index_storage_get_status,
index_storage_sync,
mbox_storage_auto_sync,
More information about the dovecot-cvs
mailing list