[dovecot-cvs] dovecot/src/lib-storage/index index-copy.c,1.19,1.20 index-expunge.c,1.11,1.12 index-fetch.c,1.31,1.32 index-status.c,1.18,1.19 index-storage.h,1.19,1.20 index-sync.c,1.18,1.19 index-update-flags.c,1.13,1.14
cras at procontrol.fi
cras at procontrol.fi
Mon Nov 4 06:47:42 EET 2002
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,1.12,1.13
- Next message: [dovecot-cvs] dovecot/src/auth userinfo-pam.c,1.5,1.6 userinfo-passwd-file.c,1.9,1.10 userinfo-passwd.c,1.4,1.5 userinfo-passwd.h,1.1.1.1,1.2 userinfo-shadow.c,1.4,1.5 userinfo-vpopmail.c,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv26855/lib-storage/index
Modified Files:
index-copy.c index-expunge.c index-fetch.c index-status.c
index-storage.h index-sync.c index-update-flags.c
Log Message:
And more locking/syncing fixes. Now it's finally beginning to look sane
again.
Index: index-copy.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-copy.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- index-copy.c 2 Nov 2002 20:10:21 -0000 1.19
+++ index-copy.c 4 Nov 2002 04:47:40 -0000 1.20
@@ -53,8 +53,8 @@
strcmp(destbox->name, box->name) == 0 ?
MAIL_LOCK_EXCLUSIVE : MAIL_LOCK_SHARED;
- if (!ibox->index->sync_and_lock(ibox->index, lock_type, NULL))
- return mail_storage_set_index_error(ibox);
+ if (!index_storage_sync_and_lock(ibox, TRUE, lock_type))
+ return FALSE;
ctx.custom_flags =
mail_custom_flags_list_get(ibox->index->custom_flags);
Index: index-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-expunge.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- index-expunge.c 2 Nov 2002 20:10:21 -0000 1.11
+++ index-expunge.c 4 Nov 2002 04:47:40 -0000 1.12
@@ -70,13 +70,17 @@
return FALSE;
}
+ if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
+ return mail_storage_set_index_error(ibox);
+
if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_EXCLUSIVE))
return FALSE;
- /* modifylog must be marked synced before expunging anything new */
- failed = !index_storage_sync_modifylog(ibox, TRUE);
-
- if (!failed)
+ /* modifylog must be marked synced before expunging
+ anything new */
+ if (!index_storage_sync_modifylog(ibox, TRUE))
+ failed = TRUE;
+ else
failed = !ibox->expunge_locked(ibox, notify);
if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
Index: index-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- index-fetch.c 2 Nov 2002 20:10:21 -0000 1.31
+++ index-fetch.c 4 Nov 2002 04:47:40 -0000 1.32
@@ -362,21 +362,21 @@
}
/* need exclusive lock to update the \Seen flags */
- if (!index_storage_sync_and_lock(ibox, TRUE, ctx.update_seen ?
- MAIL_LOCK_EXCLUSIVE :
- MAIL_LOCK_SHARED))
+ if (ctx.update_seen) {
+ if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
+ return mail_storage_set_index_error(ibox);
+ }
+
+ if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_SHARED))
return FALSE;
- if (ctx.update_seen) {
+ if (ctx.update_seen &&
+ ibox->index->header->messages_count ==
+ ibox->index->header->seen_messages_count) {
/* if all messages are already seen, there's no point in
keeping exclusive lock */
- if (ibox->index->header->messages_count ==
- ibox->index->header->seen_messages_count) {
- ctx.update_seen = FALSE;
-
- (void)ibox->index->set_lock(ibox->index,
- MAIL_LOCK_SHARED);
- }
+ ctx.update_seen = FALSE;
+ (void)ibox->index->set_lock(ibox->index, MAIL_LOCK_SHARED);
}
ctx.box = box;
Index: index-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-status.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- index-status.c 2 Nov 2002 20:10:21 -0000 1.18
+++ index-status.c 4 Nov 2002 04:47:40 -0000 1.19
@@ -75,7 +75,7 @@
/* if we're doing STATUS for selected mailbox, we have to sync it
first or STATUS reply may give different data */
- if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_SHARED))
+ if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
return FALSE;
if (!index_storage_sync_modifylog(ibox, FALSE)) {
Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- index-storage.h 3 Nov 2002 08:39:44 -0000 1.19
+++ index-storage.h 4 Nov 2002 04:47:40 -0000 1.20
@@ -38,7 +38,7 @@
int index_storage_close(Mailbox *box);
int index_storage_sync_and_lock(IndexMailbox *ibox, int sync_size,
- MailLockType lock_type);
+ MailLockType data_lock_type);
int index_storage_sync_modifylog(IndexMailbox *ibox, int hide_deleted);
int index_mailbox_fix_custom_flags(IndexMailbox *ibox, MailFlags *flags,
Index: index-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- index-sync.c 2 Nov 2002 20:10:21 -0000 1.18
+++ index-sync.c 4 Nov 2002 04:47:40 -0000 1.19
@@ -28,19 +28,14 @@
}
int index_storage_sync_and_lock(IndexMailbox *ibox, int sync_size,
- MailLockType lock_type)
+ MailLockType data_lock_type)
{
MailIndex *index = ibox->index;
- int unlock, changes;
+ int changes, set_shared_lock;
- if (lock_type != MAIL_LOCK_UNLOCK)
- unlock = FALSE;
- else {
- unlock = TRUE;
- lock_type = MAIL_LOCK_SHARED;
- }
+ set_shared_lock = ibox->index->lock_type != MAIL_LOCK_EXCLUSIVE;
- if (index->sync_and_lock(index, lock_type, &changes)) {
+ if (index->sync_and_lock(index, data_lock_type, &changes)) {
/* reset every time it has worked */
ibox->sent_diskspace_warning = FALSE;
} else {
@@ -60,13 +55,19 @@
index_reset_error(index);
}
- /* notify about changes in mailbox size. */
- if (!changes) {
- if (unlock)
+ if (set_shared_lock) {
+ /* just make sure we are locked, and that we drop our
+ exclusive lock if it wasn't wanted originally */
+ if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_SHARED)) {
(void)index->set_lock(index, MAIL_LOCK_UNLOCK);
- return TRUE; /* no changes - must be no new mail either */
+ return FALSE;
+ }
}
+ /* notify about changes in mailbox size. */
+ if (!changes)
+ return TRUE; /* no changes - must be no new mail either */
+
if (sync_size)
index_storage_sync_size(ibox);
@@ -78,9 +79,6 @@
MAIL_CUSTOM_FLAGS_COUNT, ibox->sync_context);
}
- if (unlock)
- (void)index->set_lock(index, MAIL_LOCK_UNLOCK);
-
return TRUE;
}
@@ -208,7 +206,7 @@
IndexMailbox *ibox = (IndexMailbox *) box;
int failed;
- if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_SHARED))
+ if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_UNLOCK))
return FALSE;
if (!sync_expunges) {
@@ -218,9 +216,7 @@
failed = !index_storage_sync_modifylog(ibox, FALSE);
}
- /* check size only if we're locked (== at least something changed) */
- if (ibox->index->lock_type != MAIL_LOCK_UNLOCK)
- index_storage_sync_size(ibox);
+ index_storage_sync_size(ibox);
if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
return mail_storage_set_index_error(ibox);
Index: index-update-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-update-flags.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- index-update-flags.c 2 Nov 2002 20:10:21 -0000 1.13
+++ index-update-flags.c 4 Nov 2002 04:47:40 -0000 1.14
@@ -75,7 +75,10 @@
if (!index_mailbox_fix_custom_flags(ibox, &flags, custom_flags))
return FALSE;
- if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_EXCLUSIVE))
+ if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
+ return mail_storage_set_index_error(ibox);
+
+ if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
return FALSE;
ctx.ibox = ibox;
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,1.12,1.13
- Next message: [dovecot-cvs] dovecot/src/auth userinfo-pam.c,1.5,1.6 userinfo-passwd-file.c,1.9,1.10 userinfo-passwd.c,1.4,1.5 userinfo-passwd.h,1.1.1.1,1.2 userinfo-shadow.c,1.4,1.5 userinfo-vpopmail.c,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list