[dovecot-cvs] dovecot/src/lib istream-limit.c,1.9,1.10

cras at dovecot.org cras at dovecot.org
Sun Aug 22 12:13:52 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv2122/lib

Modified Files:
	istream-limit.c 
Log Message:
Fixes for nonblocking streams.



Index: istream-limit.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream-limit.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- istream-limit.c	22 Aug 2004 07:00:51 -0000	1.9
+++ istream-limit.c	22 Aug 2004 09:13:50 -0000	1.10
@@ -53,12 +53,14 @@
 
 	stream->buffer = i_stream_get_data(lstream->input, &pos);
 	if (pos <= stream->pos) {
-		if (i_stream_read(lstream->input) == -2) {
+		if ((ret = i_stream_read(lstream->input)) == -2) {
 			if (stream->skip == 0)
 				return -2;
 		}
 		stream->istream.eof = lstream->input->eof;
 		stream->buffer = i_stream_get_data(lstream->input, &pos);
+	} else {
+		ret = 0;
 	}
 
 	stream->pos -= stream->skip;
@@ -70,8 +72,8 @@
 			pos = left;
 	}
 
-	ret = pos <= stream->pos ? -1 :
-		(ssize_t) (pos - stream->pos);
+	ret = pos > stream->pos ? (ssize_t)(pos - stream->pos) :
+		(ret == 0 ? 0 : -1);
 	stream->pos = pos;
 	return ret;
 }



More information about the dovecot-cvs mailing list