Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4777:1dc7ffa3c669 HEAD
Don't leak opened .log.2 transaction logs.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 08 Nov 2006 19:04:00 +0200 |
parents | 7abf3fbcda90 |
children | 055deed128b7 |
files | src/lib-index/mail-transaction-log-private.h src/lib-index/mail-transaction-log.c |
diffstat | 2 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-private.h Wed Nov 08 15:18:00 2006 +0200 +++ b/src/lib-index/mail-transaction-log-private.h Wed Nov 08 19:04:00 2006 +0200 @@ -38,6 +38,8 @@ struct mail_transaction_log { struct mail_index *index; struct mail_transaction_log_view *views; + /* head is the latest log file. tail is a linked list of older + files. head isn't part of that linked list at all (ugh) */ struct mail_transaction_log_file *head, *tail; unsigned int dotlock_count;
--- a/src/lib-index/mail-transaction-log.c Wed Nov 08 15:18:00 2006 +0200 +++ b/src/lib-index/mail-transaction-log.c Wed Nov 08 19:04:00 2006 +0200 @@ -267,10 +267,10 @@ mail_transaction_log_views_close(log); - if (log->head != NULL) { + if (log->head != NULL) log->head->refcount--; - mail_transaction_logs_clean(log); - } + mail_transaction_logs_clean(log); + i_assert(log->tail == NULL); *_log = NULL; log->index->log = NULL; @@ -1004,9 +1004,9 @@ } if (fstat(fd, &st) < 0) { + close_keep_errno(fd); if (errno == ESTALE) { /* treat as "doesn't exist" */ - (void)close(fd); return 0; } mail_index_file_set_syscall_error(log->index, path, "fstat()"); @@ -1026,6 +1026,8 @@ ret = mail_transaction_log_file_fd_open(log, &file, path, fd, FALSE, TRUE); if (ret <= 0) { + bool stale = errno == ESTALE; + if (ret == 0) { /* corrupted, delete it */ if (unlink(file->filepath) < 0 && errno != ENOENT) { @@ -1035,7 +1037,9 @@ mail_transaction_log_file_free(file); return 0; } - if (errno == ESTALE) { + mail_transaction_log_file_free(file); + + if (stale) { /* treat as "doesn't exist" */ return 0; }