dovecot-2.0: lib-storage: Fixed error handling in mailbox_copy().
dovecot at dovecot.org
dovecot at dovecot.org
Thu Feb 18 07:32:16 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/a792d411e73e
changeset: 10748:a792d411e73e
user: Timo Sirainen <tss at iki.fi>
date: Thu Feb 18 07:32:13 2010 +0200
description:
lib-storage: Fixed error handling in mailbox_copy().
diffstat:
src/lib-storage/mail-copy.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diffs (46 lines):
diff -r c0c4898fc803 -r a792d411e73e src/lib-storage/mail-copy.c
--- a/src/lib-storage/mail-copy.c Thu Feb 18 07:31:55 2010 +0200
+++ b/src/lib-storage/mail-copy.c Thu Feb 18 07:32:13 2010 +0200
@@ -5,7 +5,8 @@
#include "mail-storage-private.h"
#include "mail-copy.h"
-int mail_storage_copy(struct mail_save_context *ctx, struct mail *mail)
+static int
+mail_storage_try_copy(struct mail_save_context *ctx, struct mail *mail)
{
struct mail_private *pmail = (struct mail_private *)mail;
struct istream *input;
@@ -48,18 +49,26 @@
break;
} while (i_stream_read(input) != -1);
+ if (input->stream_errno != 0) {
+ mail_storage_set_critical(ctx->transaction->box->storage,
+ "copy: i_stream_read() failed: %m");
+ return -1;
+ }
+ return 0;
+}
+
+int mail_storage_copy(struct mail_save_context *ctx, struct mail *mail)
+{
if (ctx->keywords != NULL) {
- /* keywords gets unreferenced twice, because we call
- mailbox_save_cancel/finish */
+ /* keywords gets unreferenced twice: first in
+ mailbox_save_cancel()/_finish() and second time in
+ mailbox_copy(). */
mailbox_keywords_ref(ctx->transaction->box, ctx->keywords);
}
- if (input->stream_errno != 0) {
- mail_storage_set_critical(ctx->transaction->box->storage,
- "copy: i_stream_read() failed: %m");
+ if (mail_storage_try_copy(ctx, mail) < 0) {
mailbox_save_cancel(&ctx);
return -1;
}
-
return mailbox_save_finish(&ctx);
}
More information about the dovecot-cvs
mailing list