[dovecot-cvs] dovecot/src/lib-mail istream-header-filter.c, 1.4, 1.5 istream-header-filter.h, 1.2, 1.3 message-send.c, 1.22, 1.23 message-send.h, 1.12, 1.13

cras at dovecot.org cras at dovecot.org
Sun Aug 15 06:40:33 EEST 2004


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

Modified Files:
	istream-header-filter.c istream-header-filter.h message-send.c 
	message-send.h 
Log Message:
We never do blocking reads/writes to network anymore. Changed imap and pop3
processes to use a single I/O loop.

Not much tested yet, and currently LIST/LSUB may eat too much memory and
APPEND eats all CPU.



Index: istream-header-filter.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/istream-header-filter.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- istream-header-filter.c	31 Jul 2004 00:33:53 -0000	1.4
+++ istream-header-filter.c	15 Aug 2004 03:40:31 -0000	1.5
@@ -41,16 +41,6 @@
 	i_stream_set_max_buffer_size(mstream->input, max_size);
 }
 
-static void _set_blocking(struct _iostream *stream, int timeout_msecs,
-			  void (*timeout_cb)(void *), void *context)
-{
-	struct header_filter_istream *mstream =
-		(struct header_filter_istream *)stream;
-
-	i_stream_set_blocking(mstream->input, timeout_msecs,
-			      timeout_cb, context);
-}
-
 static ssize_t _read(struct _istream *stream)
 {
 	struct header_filter_istream *mstream =
@@ -136,7 +126,7 @@
 		matched = bsearch(hdr->name, headers, headers_count,
 				  sizeof(*headers), bsearch_strcasecmp) != NULL;
 		if (callback != NULL)
-			callback(hdr, matched, context);
+			callback(hdr, &matched, context);
 
 		if (matched == filter) {
 			/* ignore */
@@ -188,7 +178,6 @@
 	mstream->istream.iostream.close = _close;
 	mstream->istream.iostream.destroy = _destroy;
 	mstream->istream.iostream.set_max_buffer_size = _set_max_buffer_size;
-	mstream->istream.iostream.set_blocking = _set_blocking;
 
 	mstream->istream.read = _read;
 	mstream->istream.seek = _seek;

Index: istream-header-filter.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/istream-header-filter.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- istream-header-filter.h	18 Jul 2004 02:25:07 -0000	1.2
+++ istream-header-filter.h	15 Aug 2004 03:40:31 -0000	1.3
@@ -1,8 +1,10 @@
 #ifndef __ISTREAM_HEADER_FILTER_H
 #define __ISTREAM_HEADER_FILTER_H
 
+struct message_header_line;
+
 typedef void header_filter_callback(struct message_header_line *hdr,
-				    int matched, void *context);
+				    int *matched, void *context);
 
 /* NOTE: headers list must be sorted. If filter is TRUE, given headers are
    removed from output, otherwise only given headers are included in output. */

Index: message-send.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-send.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- message-send.c	20 Nov 2003 15:40:09 -0000	1.22
+++ message-send.c	15 Aug 2004 03:40:31 -0000	1.23
@@ -7,75 +7,6 @@
 #include "message-send.h"
 #include "message-size.h"
 
-off_t message_send(struct ostream *output, struct istream *input,
-		   const struct message_size *msg_size,
-		   int cr_skipped, uoff_t max_virtual_size, int *last_cr,
-		   int fix_nuls)
-{
-	const unsigned char *msg;
-	size_t i, size;
-	off_t ret;
-	unsigned char add;
-
-	if (last_cr != NULL)
-		*last_cr = -1;
-
-	if (msg_size->physical_size == 0)
-		return 0;
-
-	if (msg_size->physical_size == msg_size->virtual_size && !fix_nuls) {
-		/* no need to kludge with CRs, we can use sendfile() */
-		input = i_stream_create_limit(default_pool, input,
-					      input->v_offset,
-					      max_virtual_size);
-		ret = o_stream_send_istream(output, input);
-		i_stream_unref(input);
-		return ret;
-	}
-
-	/* go through the message data and insert CRs where needed.  */
-	ret = 0;
-	while (max_virtual_size > 0 &&
-	       i_stream_read_data(input, &msg, &size, 0) > 0) {
-		add = '\0';
-		for (i = 0; i < size && max_virtual_size > 0; i++) {
-			max_virtual_size--;
-
-			if (msg[i] == '\n') {
-				if ((i > 0 && msg[i-1] != '\r') ||
-				    (i == 0 && !cr_skipped)) {
-					/* missing CR */
-					add = '\r';
-					break;
-				}
-			} else if (msg[i] == '\0') {
-				add = 128;
-				break;
-			}
-		}
-
-		ret += i;
-		if (o_stream_send(output, msg, i) < 0)
-			return -1;
-
-		if (add != '\0') {
-			ret++;
-			if (o_stream_send(output, &add, 1) < 0)
-				return -1;
-			cr_skipped = add == '\r';
-			if (add == 128) i++;
-		} else {
-			cr_skipped = i > 0 && msg[i-1] == '\r';
-		}
-
-		i_stream_skip(input, i);
-	}
-
-	if (last_cr != NULL)
-		*last_cr = cr_skipped;
-	return ret;
-}
-
 void message_skip_virtual(struct istream *input, uoff_t virtual_skip,
 			  struct message_size *msg_size,
 			  int cr_skipped, int *last_cr)

Index: message-send.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-send.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- message-send.h	8 Nov 2003 20:47:07 -0000	1.12
+++ message-send.h	15 Aug 2004 03:40:31 -0000	1.13
@@ -3,15 +3,6 @@
 
 struct message_size;
 
-/* Send message to client inserting CRs if needed. Only max_virtual_size
-   bytes are sent. If cr_skipped is FALSE and input begins with LF, it's
-   treated as CRLF. last_cr is set to 1, 0 or -1 if not known. Returns number
-   of bytes sent, or -1 if error. */
-off_t message_send(struct ostream *output, struct istream *input,
-		   const struct message_size *msg_size,
-		   int cr_skipped, uoff_t max_virtual_size, int *last_cr,
-		   int fix_nuls);
-
 /* Skip number of virtual bytes from putfer. msg_size is updated if it's not
    NULL. If cr_skipped is TRUE and first character is \n, it's not treated as
    \r\n. last_cr is set to TRUE if last character we skipped was \r, meaning



More information about the dovecot-cvs mailing list