[dovecot-cvs] dovecot/src/lib ostream-file.c,1.7,1.8
cras at procontrol.fi
cras at procontrol.fi
Sat Feb 8 15:53:10 EET 2003
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv25760
Modified Files:
ostream-file.c
Log Message:
Don't bother trying sendfile() more than once with the stream.
Index: ostream-file.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ostream-file.c 27 Jan 2003 01:44:34 -0000 1.7
+++ ostream-file.c 8 Feb 2003 13:53:07 -0000 1.8
@@ -64,6 +64,7 @@
unsigned int full:1; /* if head == tail, is buffer empty or full? */
unsigned int corked:1;
unsigned int no_socket_cork:1;
+ unsigned int no_sendfile:1;
unsigned int autoclose_fd:1;
};
@@ -641,6 +642,7 @@
static off_t _send_istream(struct _ostream *outstream, struct istream *instream)
{
+ struct file_ostream *foutstream = (struct file_ostream *) outstream;
off_t ret;
i_assert(instream->v_limit <= OFF_T_MAX);
@@ -649,14 +651,17 @@
if (instream->v_offset == instream->v_limit)
return 0;
- ret = io_stream_sendfile(outstream, instream);
- if (ret >= 0 || outstream->ostream.stream_errno != EINVAL)
- return ret;
+ if (!foutstream->no_sendfile) {
+ ret = io_stream_sendfile(outstream, instream);
+ if (ret >= 0 || outstream->ostream.stream_errno != EINVAL)
+ return ret;
- /* sendfile() not supported (with this fd), fallback to
- regular sending */
+ /* sendfile() not supported (with this fd), fallback to
+ regular sending */
+ outstream->ostream.stream_errno = 0;
+ foutstream->no_sendfile = TRUE;
+ }
- outstream->ostream.stream_errno = 0;
return io_stream_copy(outstream, instream);
}
More information about the dovecot-cvs
mailing list