Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2409:9183098d7fdf HEAD
Fixed fd leaks
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 31 Jul 2004 07:14:01 +0300 |
parents | ad3983cc66cb |
children | c7c886199f28 |
files | src/lib-index/mail-index-lock.c src/lib-index/mail-index.c |
diffstat | 2 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-lock.c Sat Jul 31 06:12:37 2004 +0300 +++ b/src/lib-index/mail-index-lock.c Sat Jul 31 07:14:01 2004 +0300 @@ -180,8 +180,11 @@ return -1; if (index->lock_type == F_UNLCK) { - if (mail_index_lock_mprotect(index, F_RDLCK) < 0) + if (mail_index_lock_mprotect(index, F_RDLCK) < 0) { + (void)close(fd); + (void)unlink(path); return -1; + } } ret = write_full(fd, index->map->hdr, sizeof(*index->map->hdr)); @@ -226,6 +229,7 @@ if (mail_index_reopen(index, fd) < 0) { i_assert(index->excl_lock_count == 1); + (void)close(fd); if (unlink(index->copy_lock_path) < 0) { mail_index_file_set_syscall_error(index, index->copy_lock_path, @@ -301,6 +305,8 @@ static void mail_index_excl_unlock_finish(struct mail_index *index) { + int fd; + if (index->map != NULL && index->map->write_to_disk) { i_assert(index->log_locked); @@ -311,8 +317,11 @@ i_free(index->copy_lock_path); index->copy_lock_path = NULL; } - if (mail_index_copy(index) < 0) + fd = mail_index_copy(index); + if (fd == -1) mail_index_set_inconsistent(index); + else + (void)close(fd); } if (index->copy_lock_path != NULL) {
--- a/src/lib-index/mail-index.c Sat Jul 31 06:12:37 2004 +0300 +++ b/src/lib-index/mail-index.c Sat Jul 31 07:14:01 2004 +0300 @@ -491,8 +491,11 @@ if (ret <= 0) return ret; - if (mail_index_lock_shared(index, FALSE, &lock_id) < 0) + if (mail_index_lock_shared(index, FALSE, &lock_id) < 0) { + (void)close(index->fd); + index->fd = -1; return -1; + } ret = mail_index_map(index, FALSE); if (ret == 0) { /* it's corrupted - recreate it */