diff src/lib-storage/index/dbox-single/sdbox-file.c @ 14681:ca37d1577291

Added o_stream_nsend*() and related functions to make delayed error handling safer. Once o_stream_nsend*() is called, o_stream_nfinish() must be called before stream is destroyed to finish checking if there were any errors. If something failed and the stream is just wanted to be closed, o_stream_ignore_last_errors() can be called. For streams where errors don't really make any difference (network sockets) you can call o_stream_set_no_error_handling() immediately after creating the stream.
author Timo Sirainen <tss@iki.fi>
date Mon, 25 Jun 2012 00:01:59 +0300
parents 58732d172107
children f8c1ddf55b94
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-single/sdbox-file.c	Sun Jun 24 21:43:48 2012 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-file.c	Mon Jun 25 00:01:59 2012 +0300
@@ -310,10 +310,7 @@
 	output = o_stream_create_fd_file(out_fd, 0, FALSE);
 	i_stream_seek(file->input, 0);
 	while ((ret = o_stream_send_istream(output, file->input)) > 0) ;
-	if (ret == 0)
-		ret = o_stream_flush(output);
-	if (output->stream_errno != 0) {
-		errno = output->stream_errno;
+	if (o_stream_nfinish(output) < 0) {
 		mail_storage_set_critical(storage, "write(%s) failed: %m",
 					  temp_path);
 		ret = -1;