dovecot-2.0: lib-index: Try to keep writing to latest mailbox log.

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 28 18:29:37 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/431dff6a6ae7
changeset: 12192:431dff6a6ae7
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 28 16:29:33 2010 +0100
description:
lib-index: Try to keep writing to latest mailbox log.
Fixes a problem where a long running session keeps writing to a rotate log
that has already been deleted.

diffstat:

 src/lib-index/mailbox-log.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r e5f0231b7a40 -r 431dff6a6ae7 src/lib-index/mailbox-log.c
--- a/src/lib-index/mailbox-log.c	Tue Sep 28 16:05:40 2010 +0100
+++ b/src/lib-index/mailbox-log.c	Tue Sep 28 16:29:33 2010 +0100
@@ -1,6 +1,7 @@
 /* Copyright (c) 2009-2010 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
+#include "ioloop.h"
 #include "eacces-error.h"
 #include "mailbox-log.h"
 
@@ -14,6 +15,7 @@
 struct mailbox_log {
 	char *filepath, *filepath2;
 	int fd;
+	time_t open_timestamp;
 
 	mode_t mode;
 	gid_t gid;
@@ -81,6 +83,7 @@
 {
 	mode_t old_mode;
 
+	log->open_timestamp = ioloop_time;
 	log->fd = open(log->filepath, O_RDWR | O_APPEND);
 	if (log->fd != -1)
 		return 0;
@@ -154,11 +157,12 @@
 
 	/* we don't have to be too strict about appending to the latest log
 	   file. the records' ordering doesn't matter and iteration goes
-	   through both logs anyway. */
-	if (log->fd == -1) {
-		if (mailbox_log_open(log) < 0)
-			return -1;
-	}
+	   through both logs anyway. still, if there's a long running session
+	   it shouldn't keep writing to a rotated log forever. */
+	if (log->open_timestamp != ioloop_time)
+		mailbox_log_close(log);
+	if (mailbox_log_open(log) < 0)
+		return -1;
 
 	/* We don't bother with locking, atomic appends will protect us.
 	   If they don't (NFS), the worst that can happen is that a few


More information about the dovecot-cvs mailing list