changeset 22084:540b5d44c561

lib-storage: Fix mail_storage_last_error_push/pop() to work with internal errors
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 24 May 2017 19:16:03 +0300
parents f8e151336e0b
children 4d0e41451da1
files src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-storage-private.h	Mon May 22 17:56:15 2017 +0300
+++ b/src/lib-storage/mail-storage-private.h	Wed May 24 19:16:03 2017 +0300
@@ -105,6 +105,8 @@
 struct mail_storage_error {
 	char *error_string;
 	enum mail_error error;
+	char *last_internal_error;
+	bool last_error_is_internal;
 };
 
 struct mail_storage {
--- a/src/lib-storage/mail-storage.c	Mon May 22 17:56:15 2017 +0300
+++ b/src/lib-storage/mail-storage.c	Wed May 24 19:16:03 2017 +0300
@@ -657,6 +657,9 @@
 	err = array_append_space(&storage->error_stack);
 	err->error_string = i_strdup(storage->error_string);
 	err->error = storage->error;
+	err->last_error_is_internal = storage->last_error_is_internal;
+	if (err->last_error_is_internal)
+		err->last_internal_error = i_strdup(storage->last_internal_error);
 }
 
 void mail_storage_last_error_pop(struct mail_storage *storage)
@@ -666,8 +669,11 @@
 		array_idx(&storage->error_stack, count-1);
 
 	i_free(storage->error_string);
+	i_free(storage->last_internal_error);
 	storage->error_string = err->error_string;
 	storage->error = err->error;
+	storage->last_error_is_internal = err->last_error_is_internal;
+	storage->last_internal_error = err->last_internal_error;
 	array_delete(&storage->error_stack, count-1, 1);
 }