[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.165, 1.166 mbox-storage.h, 1.48, 1.49

tss at dovecot.org tss at dovecot.org
Thu Feb 22 17:29:49 UTC 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv21063

Modified Files:
	mbox-storage.c mbox-storage.h 
Log Message:
KEEP_LOCK: When using dotlock, touch it every 10 seconds.



Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- mbox-storage.c	22 Feb 2007 13:37:30 -0000	1.165
+++ mbox-storage.c	22 Feb 2007 17:29:46 -0000	1.166
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002-2003 Timo Sirainen */
 
 #include "lib.h"
+#include "ioloop.h"
 #include "array.h"
 #include "istream.h"
 #include "mkdir-parents.h"
@@ -20,6 +21,9 @@
 
 #define CREATE_MODE 0770 /* umask() should limit it more */
 
+/* How often to touch the dotlock file when using KEEP_LOCKED flag */
+#define MBOX_LOCK_TOUCH_MSECS (10*1000)
+
 /* Assume that if atime < mtime, there are new mails. If it's good enough for
    UW-IMAP, it's good enough for us. */
 #define STAT_GET_MARKED(st) \
@@ -516,6 +520,11 @@
 	return st.st_size / 1024 < min_size;
 }
 
+static void mbox_lock_touch_timeout(struct mbox_mailbox *mbox)
+{
+	(void)file_dotlock_touch(mbox->mbox_dotlock);
+}
+
 static struct mbox_mailbox *
 mbox_alloc(struct mbox_storage *storage, struct mail_index *index,
 	   const char *name, const char *path, enum mailbox_open_flags flags)
@@ -554,6 +563,12 @@
 			mailbox_close(&box);
 			return NULL;
 		}
+
+		if (mbox->mbox_dotlock != NULL) {
+			mbox->keep_lock_to =
+				timeout_add(MBOX_LOCK_TOUCH_MSECS,
+					    mbox_lock_touch_timeout, mbox);
+		}
 	}
 
 	index_storage_mailbox_init(&mbox->ibox, name, flags,
@@ -967,6 +982,8 @@
 
 	if (mbox->mbox_global_lock_id != 0)
 		(void)mbox_unlock(mbox, mbox->mbox_global_lock_id);
+	if (mbox->keep_lock_to != NULL)
+		timeout_remove(&mbox->keep_lock_to);
 
         mbox_file_close(mbox);
 	if (mbox->mbox_file_stream != NULL)

Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- mbox-storage.h	19 Feb 2007 14:45:52 -0000	1.48
+++ mbox-storage.h	22 Feb 2007 17:29:46 -0000	1.49
@@ -39,6 +39,7 @@
 	unsigned int mbox_excl_locks, mbox_shared_locks;
 	struct dotlock *mbox_dotlock;
 	unsigned int mbox_lock_id, mbox_global_lock_id;
+	struct timeout *keep_lock_to;
 	bool mbox_readonly, mbox_writeonly;
 	time_t mbox_dirty_stamp;
 	off_t mbox_dirty_size;



More information about the dovecot-cvs mailing list