From: Timo Sirainen Date: Thu, 16 Apr 2020 17:17:11 +0000 (+0300) Subject: lib-fs: Don't hide errors when iteration calls fs_set_error() multiple times X-Git-Tag: 2.3.11.2~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9172a1acea5fb41754153a708732dee699f1293a;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Don't hide errors when iteration calls fs_set_error() multiple times The last error is returned by fs_iter_deinit(). The other errors are logged directly. --- diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index 26d8690311..01d1aa0a61 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -619,12 +619,17 @@ fs_set_verror(struct event *event, const char *fmt, va_list args) file->last_error = new_error; } else { i_assert(iter != NULL); - /* Preserve the first error for iters. That's the first - thing that went wrong and broke the iteration. */ - if (iter->last_error == NULL) - iter->last_error = new_error; - else - i_free(new_error); + if (iter->last_error != NULL && + strcmp(iter->last_error, new_error) == 0) { + /* identical error - ignore */ + } else if (iter->last_error != NULL) { + /* multiple fs_set_error() calls before the iter + finishes */ + e_error(iter->fs->event, "%s (overwriting error)", + iter->last_error); + } + i_free(iter->last_error); + iter->last_error = new_error; } }