dovecot-2.1: lib-lda: Duplicate database write failures weren't ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 24 21:35:38 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/4edce2f57264
changeset: 14576:4edce2f57264
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jun 24 21:35:18 2012 +0300
description:
lib-lda: Duplicate database write failures weren't detected.

diffstat:

 src/lib-lda/duplicate.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r c257b9c19915 -r 4edce2f57264 src/lib-lda/duplicate.c
--- a/src/lib-lda/duplicate.c	Sun Jun 24 20:52:39 2012 +0300
+++ b/src/lib-lda/duplicate.c	Sun Jun 24 21:35:18 2012 +0300
@@ -296,7 +296,8 @@
 	hdr.version = DUPLICATE_VERSION;
 
 	output = o_stream_create_fd_file(file->new_fd, 0, FALSE);
-	o_stream_send(output, &hdr, sizeof(hdr));
+	o_stream_cork(output);
+	(void)o_stream_send(output, &hdr, sizeof(hdr));
 
 	memset(&rec, 0, sizeof(rec));
 	iter = hash_table_iterate_init(file->hash);
@@ -307,11 +308,21 @@
 		rec.id_size = d->id_size;
 		rec.user_size = strlen(d->user);
 
-		o_stream_send(output, &rec, sizeof(rec));
-		o_stream_send(output, d->id, rec.id_size);
-		o_stream_send(output, d->user, rec.user_size);
+		(void)o_stream_send(output, &rec, sizeof(rec));
+		(void)o_stream_send(output, d->id, rec.id_size);
+		(void)o_stream_send(output, d->user, rec.user_size);
 	}
+	o_stream_uncork(output);
 	hash_table_iterate_deinit(&iter);
+
+	if (output->last_failed_errno != 0) {
+		errno = output->last_failed_errno;
+		i_error("write(%s) failed: %m", file->path);
+		o_stream_unref(&output);
+		file_dotlock_delete(&file->dotlock);
+		file->new_fd = -1;
+		return;
+	}
 	o_stream_unref(&output);
 
 	file->changed = FALSE;


More information about the dovecot-cvs mailing list