[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c, 1.150, 1.151 maildir-storage.h, 1.63, 1.64 maildir-sync.c, 1.88, 1.89
tss at dovecot.org
tss at dovecot.org
Tue Mar 6 17:39:07 EET 2007
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv8171
Modified Files:
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.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- maildir-storage.c 22 Feb 2007 17:32:10 -0000 1.150
+++ maildir-storage.c 6 Mar 2007 15:39:04 -0000 1.151
@@ -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)
-
#define MAILDIR_PLUSPLUS_DRIVER_NAME "maildir++"
#define MAILDIR_SUBFOLDER_FILENAME "maildirfolder"
@@ -455,7 +452,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.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- maildir-storage.h 22 Feb 2007 12:50:15 -0000 1.63
+++ maildir-storage.h 6 Mar 2007 15:39:04 -0000 1.64
@@ -34,6 +34,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.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- maildir-sync.c 25 Jan 2007 16:01:37 -0000 1.88
+++ maildir-sync.c 6 Mar 2007 15:39:04 -0000 1.89
@@ -197,6 +197,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;
@@ -685,9 +692,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);
@@ -721,6 +731,7 @@
if (ret < 0)
break;
+ check_touch = FALSE;
flags = 0;
if (move_new) {
str_truncate(src, 0);
@@ -753,11 +764,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