dovecot-2.2: lib: Improved istream-file's failing read()/pread()...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 29 19:44:28 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/18fc72a4a318
changeset: 17849:18fc72a4a318
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 29 22:44:03 2014 +0300
description:
lib: Improved istream-file's failing read()/pread() error message.

diffstat:

 src/lib/istream-file.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r ee9cebb11e0e -r 18fc72a4a318 src/lib/istream-file.c
--- a/src/lib/istream-file.c	Mon Sep 29 22:43:44 2014 +0300
+++ b/src/lib/istream-file.c	Mon Sep 29 22:44:03 2014 +0300
@@ -54,6 +54,7 @@
 static ssize_t i_stream_file_read(struct istream_private *stream)
 {
 	struct file_istream *fstream = (struct file_istream *) stream;
+	uoff_t offset;
 	size_t size;
 	ssize_t ret;
 
@@ -65,11 +66,11 @@
 			return -1;
 	}
 
+	offset = stream->istream.v_offset + (stream->pos - stream->skip);
 	do {
 		if (fstream->file) {
 			ret = pread(stream->fd, stream->w_buffer + stream->pos,
-				    size, stream->istream.v_offset +
-				    (stream->pos - stream->skip));
+				    size, offset);
 		} else if (fstream->seen_eof) {
 			/* don't try to read() again. EOF from keyboard (^D)
 			   requires this to work right. */
@@ -97,6 +98,16 @@
 			/* if we get EBADF for a valid fd, it means something's
 			   really wrong and we'd better just crash. */
 			i_assert(errno != EBADF);
+			if (fstream->file) {
+				io_stream_set_error(&stream->iostream,
+					"pread(size=%"PRIuSIZE_T
+					" offset=%"PRIuUOFF_T") failed: %m",
+					size, offset);
+			} else {
+				io_stream_set_error(&stream->iostream,
+					"read(size=%"PRIuSIZE_T") failed: %m",
+					size);
+			}
 			stream->istream.stream_errno = errno;
 			return -1;
 		}


More information about the dovecot-cvs mailing list