[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c, 1.115.2.25, 1.115.2.26 maildir-storage.h, 1.49.2.7, 1.49.2.8 maildir-sync.c, 1.77.2.4, 1.77.2.5
tss at dovecot.org
tss at dovecot.org
Tue Mar 6 17:39:03 EET 2007
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv8105
Modified Files:
Tag: branch_1_0
maildir-storage.c maildir-storage.h maildir-sync.c
Log Message:
When syncing huge maildirs check once in a while if we need to update
dovecot-uidlist.lock so that another process won't decide that it's stale
and overwrite it. Check more often when moving mails from new/ to cur/.
Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.115.2.25
retrieving revision 1.115.2.26
diff -u -d -r1.115.2.25 -r1.115.2.26
--- maildir-storage.c 22 Feb 2007 13:37:32 -0000 1.115.2.25
+++ maildir-storage.c 6 Mar 2007 15:39:01 -0000 1.115.2.26
@@ -20,9 +20,6 @@
#define CREATE_MODE 0777 /* umask() should limit it more */
-/* How often to touch the uidlist lock file when using KEEP_LOCKED flag */
-#define MAILDIR_LOCK_TOUCH_MSECS (10*1000)
-
/* Don't allow creating too long mailbox names. They could start causing
problems when they reach the limit. */
#define MAILDIR_MAX_MAILBOX_NAME_LENGTH (PATH_MAX/2)
@@ -543,7 +540,7 @@
mailbox_close(&box);
return NULL;
}
- mbox->keep_lock_to = timeout_add(MAILDIR_LOCK_TOUCH_MSECS,
+ mbox->keep_lock_to = timeout_add(MAILDIR_LOCK_TOUCH_SECS * 1000,
maildir_lock_touch_timeout,
mbox);
}
Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.49.2.7
retrieving revision 1.49.2.8
diff -u -d -r1.49.2.7 -r1.49.2.8
--- maildir-storage.h 22 Feb 2007 12:50:09 -0000 1.49.2.7
+++ maildir-storage.h 6 Mar 2007 15:39:01 -0000 1.49.2.8
@@ -37,6 +37,11 @@
/* Delete files having ctime older than this from tmp/. 36h is standard. */
#define MAILDIR_TMP_DELETE_SECS (36*60*60)
+/* How often to touch the uidlist lock file when it's locked.
+ This is done both when using KEEP_LOCKED flag and when syncing a large
+ maildir. */
+#define MAILDIR_LOCK_TOUCH_SECS 10
+
#define MAILDIR_SAVE_FLAG_HARDLINK 0x10000000
#define MAILDIR_SAVE_FLAG_DELETED 0x20000000
Index: maildir-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.77.2.4
retrieving revision 1.77.2.5
diff -u -d -r1.77.2.4 -r1.77.2.5
--- maildir-sync.c 25 Jan 2007 16:01:34 -0000 1.77.2.4
+++ maildir-sync.c 6 Mar 2007 15:39:01 -0000 1.77.2.5
@@ -198,6 +198,13 @@
bet here, but I guess 5 will do just fine too. */
#define MAILDIR_RENAME_RESCAN_COUNT 5
+/* After moving 100 mails from new/ to cur/, check if we need to touch the
+ uidlist lock. */
+#define MAILDIR_SLOW_MOVE_COUNT 100
+/* readdir() should be pretty fast to do, but check anyway every 10000 mails
+ to see if we need to touch the uidlist lock. */
+#define MAILDIR_SLOW_CHECK_COUNT 10000
+
struct maildir_sync_context {
struct maildir_mailbox *mbox;
const char *new_dir, *cur_dir;
@@ -689,9 +696,12 @@
string_t *src, *dest;
struct dirent *dp;
enum maildir_uidlist_rec_flag flags;
- unsigned int moves = 0;
+ time_t last_touch;
+ unsigned int moves = 0, count = 0;
int ret = 1;
- bool move_new;
+ bool move_new, check_touch;
+
+ last_touch = ioloop_time;
dir = new_dir ? ctx->new_dir : ctx->cur_dir;
dirp = opendir(dir);
@@ -725,6 +735,7 @@
if (ret < 0)
break;
+ check_touch = FALSE;
flags = 0;
if (move_new) {
str_truncate(src, 0);
@@ -757,11 +768,24 @@
"rename(%s, %s) failed: %m",
str_c(src), str_c(dest));
}
+ if ((moves % MAILDIR_SLOW_MOVE_COUNT) == 0)
+ check_touch = TRUE;
} else if (new_dir) {
flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR |
MAILDIR_UIDLIST_REC_FLAG_RECENT;
}
+ count++;
+ if (check_touch || (count % MAILDIR_SLOW_CHECK_COUNT) == 0) {
+ time_t now = time(NULL);
+
+ if (now - last_touch > MAILDIR_LOCK_TOUCH_SECS) {
+ (void)maildir_uidlist_lock_touch(
+ ctx->mbox->uidlist);
+ last_touch = now;
+ }
+ }
+
ret = maildir_uidlist_sync_next(ctx->uidlist_sync_ctx,
dp->d_name, flags);
if (ret <= 0) {
More information about the dovecot-cvs
mailing list