[dovecot-cvs] dovecot/src/lib ostream-file.c,1.64,1.65
tss at dovecot.org
tss at dovecot.org
Wed Dec 20 15:40:24 UTC 2006
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv22494
Modified Files:
ostream-file.c
Log Message:
Delay setting the TCP cork until something is actually sent to the
network.
Index: ostream-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- ostream-file.c 15 Dec 2006 18:38:10 -0000 1.64
+++ ostream-file.c 20 Dec 2006 15:40:22 -0000 1.65
@@ -42,6 +42,7 @@
unsigned int file:1;
unsigned int corked:1;
unsigned int flush_pending:1;
+ unsigned int socket_cork_set:1;
unsigned int no_socket_cork:1;
unsigned int no_sendfile:1;
unsigned int autoclose_fd:1;
@@ -120,6 +121,18 @@
fstream->head = 0;
}
+static void o_stream_socket_cork(struct file_ostream *fstream)
+{
+ if (fstream->corked && !fstream->socket_cork_set) {
+ if (!fstream->no_socket_cork) {
+ if (net_set_cork(fstream->fd, TRUE) < 0)
+ fstream->no_socket_cork = TRUE;
+ else
+ fstream->socket_cork_set = TRUE;
+ }
+ }
+}
+
static ssize_t o_stream_writev(struct file_ostream *fstream,
const struct const_iovec *iov, int iov_size)
{
@@ -127,6 +140,7 @@
size_t size, sent;
int i;
+ o_stream_socket_cork(fstream);
if (iov_size == 1)
ret = write(fstream->fd, iov->iov_base, iov->iov_len);
else {
@@ -226,9 +240,11 @@
}
}
- if (!fstream->no_socket_cork) {
- if (net_set_cork(fstream->fd, set) < 0)
+ if (fstream->socket_cork_set) {
+ i_assert(!set);
+ if (net_set_cork(fstream->fd, FALSE) < 0)
fstream->no_socket_cork = TRUE;
+ fstream->socket_cork_set = FALSE;
}
fstream->corked = set;
}
@@ -487,6 +503,8 @@
uoff_t offset, send_size, v_offset;
ssize_t ret;
+ o_stream_socket_cork(foutstream);
+
/* flush out any data in buffer */
if ((ret = buffer_flush(foutstream)) <= 0)
return ret;
More information about the dovecot-cvs
mailing list