changeset 6564:c4fa8b1ee24a HEAD

Set blocking/seekable flags.
author Timo Sirainen <tss@iki.fi>
date Sat, 20 Oct 2007 19:25:35 +0300
parents d85bfe89f4b8
children b39233d16d0f
files src/lib/istream-concat.c src/lib/istream-seekable.c
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/istream-concat.c	Sat Oct 20 19:21:15 2007 +0300
+++ b/src/lib/istream-concat.c	Sat Oct 20 19:25:35 2007 +0300
@@ -219,11 +219,19 @@
 	struct concat_istream *cstream;
 	unsigned int count;
 	size_t max_buffer_size = I_STREAM_MIN_SIZE;
+	bool blocking = TRUE, seekable = TRUE;
 
+	/* if any of the streams isn't blocking or seekable, set ourself also
+	   nonblocking/nonseekable */
 	for (count = 0; input[count] != NULL; count++) {
 		size_t cur_max = input[count]->real_stream->max_buffer_size;
+
 		if (cur_max > max_buffer_size)
 			max_buffer_size = cur_max;
+		if (!input[count]->blocking)
+			blocking = FALSE;
+		if (!input[count]->seekable)
+			seekable = FALSE;
 		i_stream_ref(input[count]);
 	}
 	i_assert(count != 0);
@@ -245,5 +253,7 @@
 	cstream->istream.seek = i_stream_concat_seek;
 	cstream->istream.stat = i_stream_concat_stat;
 
+	cstream->istream.istream.blocking = blocking;
+	cstream->istream.istream.seekable = seekable;
 	return i_stream_create(&cstream->istream, -1, 0);
 }
--- a/src/lib/istream-seekable.c	Sat Oct 20 19:21:15 2007 +0300
+++ b/src/lib/istream-seekable.c	Sat Oct 20 19:25:35 2007 +0300
@@ -301,9 +301,14 @@
 	const unsigned char *data;
 	unsigned int count;
 	size_t size;
+	bool blocking = TRUE;
 
-	for (count = 0; input[count] != NULL; count++)
+	/* if any of the streams isn't blocking, set ourself also nonblocking */
+	for (count = 0; input[count] != NULL; count++) {
+		if (!input[count]->blocking)
+			blocking = FALSE;
 		i_stream_ref(input[count]);
+	}
 	i_assert(count != 0);
 
 	sstream = i_new(struct seekable_istream, 1);
@@ -329,5 +334,7 @@
 	sstream->istream.seek = i_stream_seekable_seek;
 	sstream->istream.stat = i_stream_seekable_stat;
 
+	sstream->istream.istream.blocking = blocking;
+	sstream->istream.istream.seekable = TRUE;
 	return i_stream_create(&sstream->istream, -1, 0);
 }