dovecot-2.2: istream filters: If parent's i_stream_stat() fails,...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 30 11:01:07 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/ac64c307d179
changeset: 18896:ac64c307d179
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 30 12:18:08 2015 +0300
description:
istream filters: If parent's i_stream_stat() fails, copy the stream_errno.
This doesn't actually change any functionality yet, since most
i_stream_stat() callers aren't using i_stream_get_error().

diffstat:

 src/lib-compression/istream-bzlib.c           |  4 +++-
 src/lib-compression/istream-lz4.c             |  4 +++-
 src/lib-compression/istream-lzma.c            |  4 +++-
 src/lib-compression/istream-zlib.c            |  4 +++-
 src/lib-fs/istream-metawrap.c                 |  4 +++-
 src/lib-mail/istream-header-filter.c          |  4 +++-
 src/lib-storage/index/mbox/istream-raw-mbox.c |  4 +++-
 src/lib/istream-limit.c                       |  4 +++-
 src/lib/istream-sized.c                       |  4 +++-
 src/lib/istream.c                             |  8 ++++++--
 src/plugins/mail-filter/istream-ext-filter.c  |  4 +++-
 11 files changed, 36 insertions(+), 12 deletions(-)

diffs (177 lines):

diff -r d4422b0560fe -r ac64c307d179 src/lib-compression/istream-bzlib.c
--- a/src/lib-compression/istream-bzlib.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-compression/istream-bzlib.c	Tue Jun 30 12:18:08 2015 +0300
@@ -266,8 +266,10 @@
 	const struct stat *st;
 	size_t size;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 
 	/* when exact=FALSE always return the parent stat's size, even if we
diff -r d4422b0560fe -r ac64c307d179 src/lib-compression/istream-lz4.c
--- a/src/lib-compression/istream-lz4.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-compression/istream-lz4.c	Tue Jun 30 12:18:08 2015 +0300
@@ -249,8 +249,10 @@
 	const struct stat *st;
 	size_t size;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 
 	/* when exact=FALSE always return the parent stat's size, even if we
diff -r d4422b0560fe -r ac64c307d179 src/lib-compression/istream-lzma.c
--- a/src/lib-compression/istream-lzma.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-compression/istream-lzma.c	Tue Jun 30 12:18:08 2015 +0300
@@ -275,8 +275,10 @@
 	const struct stat *st;
 	size_t size;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 
 	/* when exact=FALSE always return the parent stat's size, even if we
diff -r d4422b0560fe -r ac64c307d179 src/lib-compression/istream-zlib.c
--- a/src/lib-compression/istream-zlib.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-compression/istream-zlib.c	Tue Jun 30 12:18:08 2015 +0300
@@ -417,8 +417,10 @@
 	const struct stat *st;
 	size_t size;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 
 	/* when exact=FALSE always return the parent stat's size, even if we
diff -r d4422b0560fe -r ac64c307d179 src/lib-fs/istream-metawrap.c
--- a/src/lib-fs/istream-metawrap.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-fs/istream-metawrap.c	Tue Jun 30 12:18:08 2015 +0300
@@ -92,8 +92,10 @@
 	const struct stat *st;
 	int ret;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 
 	if (mstream->in_metadata) {
diff -r d4422b0560fe -r ac64c307d179 src/lib-mail/istream-header-filter.c
--- a/src/lib-mail/istream-header-filter.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-mail/istream-header-filter.c	Tue Jun 30 12:18:08 2015 +0300
@@ -505,8 +505,10 @@
 	const struct stat *st;
 	uoff_t old_offset;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 	if (stream->statbuf.st_size == -1 || !exact)
 		return 0;
diff -r d4422b0560fe -r ac64c307d179 src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c	Tue Jun 30 12:18:08 2015 +0300
@@ -417,8 +417,10 @@
 	const struct stat *st;
 	struct raw_mbox_istream *rstream = (struct raw_mbox_istream *)stream;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 
 	stream->statbuf = *st;
 	stream->statbuf.st_size =
diff -r d4422b0560fe -r ac64c307d179 src/lib/istream-limit.c
--- a/src/lib/istream-limit.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib/istream-limit.c	Tue Jun 30 12:18:08 2015 +0300
@@ -77,8 +77,10 @@
 	struct limit_istream *lstream = (struct limit_istream *) stream;
 	const struct stat *st;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 
 	stream->statbuf = *st;
 	if (lstream->v_size != (uoff_t)-1)
diff -r d4422b0560fe -r ac64c307d179 src/lib/istream-sized.c
--- a/src/lib/istream-sized.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib/istream-sized.c	Tue Jun 30 12:18:08 2015 +0300
@@ -98,8 +98,10 @@
 	/* parent stream may be base64-decoder. don't waste time decoding the
 	   entire stream, since we already know what the size is supposed
 	   to be. */
-	if (i_stream_stat(stream->parent, FALSE, &st) < 0)
+	if (i_stream_stat(stream->parent, FALSE, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 
 	stream->statbuf = *st;
 	stream->statbuf.st_size = sstream->size;
diff -r d4422b0560fe -r ac64c307d179 src/lib/istream.c
--- a/src/lib/istream.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/lib/istream.c	Tue Jun 30 12:18:08 2015 +0300
@@ -767,8 +767,10 @@
 	if (stream->parent == NULL)
 		return stream->istream.stream_errno == 0 ? 0 : -1;
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 	if (exact && !stream->stream_size_passthrough) {
 		/* exact size is not known, even if parent returned something */
@@ -781,8 +783,10 @@
 i_stream_default_get_size(struct istream_private *stream,
 			  bool exact, uoff_t *size_r)
 {
-	if (stream->stat(stream, exact) < 0)
+	if (stream->stat(stream, exact) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	if (stream->statbuf.st_size == -1)
 		return 0;
 
diff -r d4422b0560fe -r ac64c307d179 src/plugins/mail-filter/istream-ext-filter.c
--- a/src/plugins/mail-filter/istream-ext-filter.c	Tue Jun 30 12:17:35 2015 +0300
+++ b/src/plugins/mail-filter/istream-ext-filter.c	Tue Jun 30 12:18:08 2015 +0300
@@ -135,8 +135,10 @@
 
 	i_assert(!exact);
 
-	if (i_stream_stat(stream->parent, exact, &st) < 0)
+	if (i_stream_stat(stream->parent, exact, &st) < 0) {
+		stream->istream.stream_errno = stream->parent->stream_errno;
 		return -1;
+	}
 	stream->statbuf = *st;
 	return 0;
 }


More information about the dovecot-cvs mailing list