[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.145.2.9, 1.145.2.10 mbox-storage.h, 1.43.2.1, 1.43.2.2

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


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

Modified Files:
      Tag: branch_1_0
	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.145.2.9
retrieving revision 1.145.2.10
diff -u -d -r1.145.2.9 -r1.145.2.10
--- mbox-storage.c	22 Feb 2007 13:37:37 -0000	1.145.2.9
+++ mbox-storage.c	22 Feb 2007 17:29:43 -0000	1.145.2.10
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002-2003 Timo Sirainen */
 
 #include "lib.h"
+#include "ioloop.h"
 #include "buffer.h"
 #include "istream.h"
 #include "home-expand.h"
@@ -22,6 +23,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)
+
 /* Don't allow creating too long mailbox names. They could start causing
    problems when they reach the limit. */
 #define MBOX_MAX_MAILBOX_NAME_LENGTH (PATH_MAX/2)
@@ -564,6 +568,13 @@
 	return st.st_size / 1024 < min_size;
 }
 
+static void mbox_lock_touch_timeout(void *context)
+{
+	struct mbox_mailbox *mbox = context;
+
+	(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)
@@ -602,6 +613,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,
@@ -1092,6 +1109,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.43.2.1
retrieving revision 1.43.2.2
diff -u -d -r1.43.2.1 -r1.43.2.2
--- mbox-storage.h	19 Feb 2007 14:45:47 -0000	1.43.2.1
+++ mbox-storage.h	22 Feb 2007 17:29:43 -0000	1.43.2.2
@@ -35,6 +35,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