[dovecot-cvs] dovecot/src/lib ostream-file.c, 1.51, 1.52 ostream-internal.h, 1.5, 1.6 ostream.c, 1.12, 1.13 ostream.h, 1.11, 1.12

cras at dovecot.org cras at dovecot.org
Sun Sep 25 13:49:06 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv8370

Modified Files:
	ostream-file.c ostream-internal.h ostream.c ostream.h 
Log Message:
Changed iov_count to be unsigned int, it's large enough. Added overflow-flag
which gets sent if send() failed to both send and buffer the given data.



Index: ostream-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- ostream-file.c	29 May 2005 10:50:06 -0000	1.51
+++ ostream-file.c	25 Sep 2005 10:49:03 -0000	1.52
@@ -420,10 +420,11 @@
 }
 
 static ssize_t _sendv(struct _ostream *stream, const struct const_iovec *iov,
-		      size_t iov_count)
+		      unsigned int iov_count)
 {
 	struct file_ostream *fstream = (struct file_ostream *)stream;
-	size_t i, size, added, optimal_size;
+	size_t size, added, optimal_size;
+	unsigned int i;
 	ssize_t ret = 0;
 
 	stream->ostream.stream_errno = 0;
@@ -431,7 +432,7 @@
 	for (i = 0, size = 0; i < iov_count; i++)
 		size += iov[i].iov_len;
 
-	if (size > get_unused_space(fstream)) {
+	if (size > get_unused_space(fstream) && !IS_STREAM_EMPTY(fstream)) {
 		if (_flush(stream) < 0)
 			return -1;
 	}

Index: ostream-internal.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-internal.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ostream-internal.h	26 Apr 2005 10:43:57 -0000	1.5
+++ ostream-internal.h	25 Sep 2005 10:49:03 -0000	1.6
@@ -15,7 +15,7 @@
 	size_t (*get_used_size)(struct _ostream *stream);
 	int (*seek)(struct _ostream *stream, uoff_t offset);
 	ssize_t (*sendv)(struct _ostream *stream, const struct const_iovec *iov,
-			 size_t iov_count);
+			 unsigned int iov_count);
 	off_t (*send_istream)(struct _ostream *outstream,
 			      struct istream *instream);
 

Index: ostream.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- ostream.c	26 Apr 2005 10:43:57 -0000	1.12
+++ ostream.c	25 Sep 2005 10:49:03 -0000	1.13
@@ -101,14 +101,23 @@
 }
 
 ssize_t o_stream_sendv(struct ostream *stream, const struct const_iovec *iov,
-		       size_t iov_count)
+		       unsigned int iov_count)
 {
 	struct _ostream *_stream = stream->real_stream;
+	unsigned int i;
+	size_t total_size;
+	ssize_t ret;
 
 	if (stream->closed)
 		return -1;
 
-	return _stream->sendv(_stream, iov, iov_count);
+	for (i = 0, total_size = 0; i < iov_count; i++)
+		total_size += iov[i].iov_len;
+
+	ret = _stream->sendv(_stream, iov, iov_count);
+	if (ret != (ssize_t)total_size)
+		stream->overflow = TRUE;
+	return ret;
 }
 
 ssize_t o_stream_send_str(struct ostream *stream, const char *str)

Index: ostream.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ostream.h	26 Apr 2005 10:43:57 -0000	1.11
+++ ostream.h	25 Sep 2005 10:49:03 -0000	1.12
@@ -7,6 +7,10 @@
 	uoff_t offset;
 
 	int stream_errno;
+	/* overflow is set when some of the data given to send()
+	   functions was neither sent nor buffered. It's never unset inside
+	   ostream code. */
+	unsigned int overflow:1;
 	unsigned int closed:1;
 
 	struct _ostream *real_stream;
@@ -58,7 +62,7 @@
 /* Returns number of bytes sent, -1 = error */
 ssize_t o_stream_send(struct ostream *stream, const void *data, size_t size);
 ssize_t o_stream_sendv(struct ostream *stream, const struct const_iovec *iov,
-		       size_t iov_count);
+		       unsigned int iov_count);
 ssize_t o_stream_send_str(struct ostream *stream, const char *str);
 /* Send data from input stream. Returns number of bytes sent, or -1 if error.
    Note that this function may block if either instream or outstream is



More information about the dovecot-cvs mailing list