dovecot-2.2: iostream-temp: Don't try to dup() the stream fd if ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 4 22:03:24 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/6a6472846181
changeset: 15731:6a6472846181
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 04 22:03:10 2013 +0200
description:
iostream-temp: Don't try to dup() the stream fd if it's already closed.

diffstat:

 src/lib/iostream-temp.c |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (22 lines):

diff -r a1598c03c940 -r 6a6472846181 src/lib/iostream-temp.c
--- a/src/lib/iostream-temp.c	Mon Feb 04 22:02:42 2013 +0200
+++ b/src/lib/iostream-temp.c	Mon Feb 04 22:03:10 2013 +0200
@@ -220,7 +220,7 @@
 	uoff_t abs_offset, size;
 	int fd;
 
-	if (tstream->dupstream != NULL) {
+	if (tstream->dupstream != NULL && !tstream->dupstream->closed) {
 		abs_offset = tstream->dupstream->real_stream->abs_start_offset +
 			tstream->dupstream_start_offset;
 		size = tstream->dupstream_offset -
@@ -235,6 +235,9 @@
 			i_stream_unref(&input2);
 		}
 		i_stream_unref(&tstream->dupstream);
+	} else if (tstream->dupstream != NULL) {
+		/* return the original failed stream. */
+		input = tstream->dupstream;
 	} else if (tstream->fd != -1) {
 		input = i_stream_create_fd(tstream->fd, max_buffer_size, TRUE);
 		tstream->fd = -1;


More information about the dovecot-cvs mailing list