From: Timo Sirainen Date: Fri, 29 Nov 2019 15:49:23 +0000 (+0200) Subject: lib-fs: Log any pending errors in fs_file_deinit() X-Git-Tag: 2.3.10~202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26673b961fb09e2c74b9968f9bfb25f86169d8b8;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Log any pending errors in fs_file_deinit() If error was set to the file but it wasn't accessed with fs_file_last_error(), it means the error message would become lost. Usually this is probably not intended. --- diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index ec8d9bd7d4..2bc43110f1 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -306,6 +306,14 @@ void fs_file_deinit(struct fs_file **_file) void fs_file_free(struct fs_file *file) { + if (file->last_error_changed) { + /* fs_set_error() used without ever accessing it via + fs_file_last_error(). Log it to make sure it's not lost. + Note that the errors are always set only to the file at + the root of the parent hierarchy. */ + e_error(file->event, "%s (in file deinit)", file->last_error); + } + fs_file_deinit(&file->parent); event_unref(&file->event); pool_unref(&file->metadata_pool);