]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Log any pending errors in fs_file_deinit()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 29 Nov 2019 15:49:23 +0000 (17:49 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 11 Dec 2019 10:12:30 +0000 (10:12 +0000)
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.

src/lib-fs/fs-api.c

index ec8d9bd7d41978dd057305d9f6713b94a0a39773..2bc43110f10b7b95ee9fdd42c26840aa08a35fbb 100644 (file)
@@ -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);