From cbd6cad82e1c9ad60869ad71ae6c42e1af8b10a8 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 4 Oct 2010 15:55:34 +0100 Subject: [PATCH] lib-index: Fixed leaking fds when writing to dovecot.mailbox.log --- src/lib-index/mailbox-log.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib-index/mailbox-log.c b/src/lib-index/mailbox-log.c index 7dfb3c1b95..90ae333bdb 100644 --- a/src/lib-index/mailbox-log.c +++ b/src/lib-index/mailbox-log.c @@ -83,6 +83,8 @@ static int mailbox_log_open(struct mailbox_log *log) { mode_t old_mode; + i_assert(log->fd == -1); + log->open_timestamp = ioloop_time; log->fd = open(log->filepath, O_RDWR | O_APPEND); if (log->fd != -1) @@ -161,8 +163,10 @@ int mailbox_log_append(struct mailbox_log *log, 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; + if (log->fd == -1) { + 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 -- 2.47.3