dovecot-2.2: Added istreams_merge(), which forces istream-seekab...

dovecot at dovecot.org dovecot at dovecot.org
Sat Aug 11 05:19:35 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/39f23dcb9e18
changeset: 14856:39f23dcb9e18
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Aug 11 05:17:58 2012 +0300
description:
Added istreams_merge(), which forces istream-seekable to be created.

diffstat:

 src/lib/istream-seekable.c |  34 ++++++++++++++++++++++------------
 src/lib/istream-seekable.h |   7 +++++++
 2 files changed, 29 insertions(+), 12 deletions(-)

diffs (72 lines):

diff -r 2a973e6c25f8 -r 39f23dcb9e18 src/lib/istream-seekable.c
--- a/src/lib/istream-seekable.c	Sat Aug 11 05:17:19 2012 +0300
+++ b/src/lib/istream-seekable.c	Sat Aug 11 05:17:58 2012 +0300
@@ -333,10 +333,9 @@
 }
 
 struct istream *
-i_stream_create_seekable(struct istream *input[],
-			 size_t max_buffer_size,
-			 int (*fd_callback)(const char **path_r, void *context),
-			 void *context)
+i_streams_merge(struct istream *input[], size_t max_buffer_size,
+		int (*fd_callback)(const char **path_r, void *context),
+		void *context) ATTR_NULL(4)
 {
 	struct seekable_istream *sstream;
 	const unsigned char *data;
@@ -344,14 +343,6 @@
 	size_t size;
 	bool blocking = TRUE;
 
-	/* If all input streams are seekable, use concat istream instead */
-	for (count = 0; input[count] != NULL; count++) {
-		if (!input[count]->seekable)
-			break;
-	}
-	if (input[count] == NULL)
-		return i_stream_create_concat(input);
-
 	/* if any of the streams isn't blocking, set ourself also nonblocking */
 	for (count = 0; input[count] != NULL; count++) {
 		if (!input[count]->blocking)
@@ -390,3 +381,22 @@
 	sstream->istream.istream.seekable = TRUE;
 	return i_stream_create(&sstream->istream, NULL, -1);
 }
+
+struct istream *
+i_stream_create_seekable(struct istream *input[],
+			 size_t max_buffer_size,
+			 int (*fd_callback)(const char **path_r, void *context),
+			 void *context)
+{
+	unsigned int count;
+
+	/* If all input streams are seekable, use concat istream instead */
+	for (count = 0; input[count] != NULL; count++) {
+		if (!input[count]->seekable)
+			break;
+	}
+	if (input[count] == NULL)
+		return i_stream_create_concat(input);
+
+	return i_streams_merge(input, max_buffer_size, fd_callback, context);
+}
diff -r 2a973e6c25f8 -r 39f23dcb9e18 src/lib/istream-seekable.h
--- a/src/lib/istream-seekable.h	Sat Aug 11 05:17:19 2012 +0300
+++ b/src/lib/istream-seekable.h	Sat Aug 11 05:17:58 2012 +0300
@@ -8,6 +8,13 @@
    the fd and path of the created file. Typically the callback would also
    unlink the file before returning. */
 struct istream *
+i_streams_merge(struct istream *input[], size_t max_buffer_size,
+		int (*fd_callback)(const char **path_r, void *context),
+		void *context) ATTR_NULL(4);
+
+/* Same as i_streams_merge(), but if all of the inputs are seekable already,
+   create a concat stream instead. */
+struct istream *
 i_stream_create_seekable(struct istream *input[],
 			 size_t max_buffer_size,
 			 int (*fd_callback)(const char **path_r, void *context),


More information about the dovecot-cvs mailing list