dovecot: fd leak fix
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 9 05:44:41 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/171c3f89295c
changeset: 5915:171c3f89295c
user: Timo Sirainen <tss at iki.fi>
date: Sun Jul 08 22:57:51 2007 +0300
description:
fd leak fix
diffstat:
1 file changed, 14 insertions(+), 11 deletions(-)
src/lib-storage/index/maildir/maildir-uidlist.c | 25 ++++++++++++-----------
diffs (52 lines):
diff -r ae731dbf3a6f -r 171c3f89295c src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Sun Jul 08 22:54:55 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c Sun Jul 08 22:57:51 2007 +0300
@@ -208,14 +208,21 @@ struct maildir_uidlist *maildir_uidlist_
return uidlist;
}
-void maildir_uidlist_deinit(struct maildir_uidlist *uidlist)
-{
- i_assert(!UIDLIST_IS_LOCKED(uidlist));
-
+static void maildir_uidlist_close(struct maildir_uidlist *uidlist)
+{
if (uidlist->fd != -1) {
if (close(uidlist->fd) < 0)
i_error("close(%s) failed: %m", uidlist->fname);
- }
+ uidlist->fd = -1;
+ uidlist->fd_ino = 0;
+ }
+}
+
+void maildir_uidlist_deinit(struct maildir_uidlist *uidlist)
+{
+ i_assert(!UIDLIST_IS_LOCKED(uidlist));
+
+ maildir_uidlist_close(uidlist);
hash_destroy(uidlist->files);
if (uidlist->record_pool != NULL)
@@ -310,12 +317,7 @@ maildir_uidlist_update_read(struct maild
*retry_r = FALSE;
- if (uidlist->fd != -1) {
- if (close(uidlist->fd) < 0)
- i_error("close(%s) failed: %m", uidlist->fname);
- uidlist->fd = -1;
- uidlist->fd_ino = 0;
- }
+ maildir_uidlist_close(uidlist);
fd = nfs_safe_open(uidlist->fname, O_RDONLY);
if (fd == -1) {
@@ -683,6 +685,7 @@ static int maildir_uidlist_rewrite(struc
(void)close(uidlist->lock_fd);
ret = -1;
} else {
+ maildir_uidlist_close(uidlist);
uidlist->fd = uidlist->lock_fd;
if (fstat(uidlist->fd, &st) < 0) {
i_error("fstat(%s) failed: %m", uidlist->fname);
More information about the dovecot-cvs
mailing list