[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-storage.c, 1.15.2.5, 1.15.2.6 dbox-uidlist.c, 1.28.2.5, 1.28.2.6 dbox-uidlist.h, 1.5.2.1, 1.5.2.2
cras at dovecot.org
cras at dovecot.org
Sun Jul 23 17:21:01 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-storage/index/dbox
In directory talvi:/tmp/cvs-serv13218
Modified Files:
Tag: branch_1_0
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.15.2.5
retrieving revision 1.15.2.6
diff -u -d -r1.15.2.5 -r1.15.2.6
--- dbox-storage.c 17 Jun 2006 13:02:03 -0000 1.15.2.5
+++ dbox-storage.c 23 Jul 2006 14:20:58 -0000 1.15.2.6
@@ -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.28.2.5
retrieving revision 1.28.2.6
diff -u -d -r1.28.2.5 -r1.28.2.6
--- dbox-uidlist.c 16 Jun 2006 08:37:37 -0000 1.28.2.5
+++ dbox-uidlist.c 23 Jul 2006 14:20:58 -0000 1.28.2.6
@@ -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;
@@ -443,9 +444,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,
@@ -456,13 +463,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.5.2.1
retrieving revision 1.5.2.2
diff -u -d -r1.5.2.1 -r1.5.2.2
--- dbox-uidlist.h 8 Jun 2006 18:21:12 -0000 1.5.2.1
+++ dbox-uidlist.h 23 Jul 2006 14:20:58 -0000 1.5.2.2
@@ -18,6 +18,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