Mercurial > dovecot > core-2.2
changeset 1345:04b81672c3a3 HEAD
Call safe_sendfile() only with sockets, and also with files under Linux.
Hopefully helps for signal 12 under FreeBSD.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Apr 2003 23:28:30 +0300 |
parents | 2dcd8cebe5e6 |
children | 6fa223de19f9 |
files | src/lib/ostream-file.c src/lib/sendfile-util.c |
diffstat | 2 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/ostream-file.c Wed Apr 09 23:13:02 2003 +0300 +++ b/src/lib/ostream-file.c Wed Apr 09 23:28:30 2003 +0300 @@ -876,6 +876,15 @@ fstream->optimal_block_size = I_MIN(st.st_blksize, MAX_OPTIMAL_BLOCK_SIZE); } +#ifndef HAVE_LINUX_SENDFILE + /* only Linux supports sendfile() with non-sockets. Other + systems fail more or less gracefully if it's tried, so + don't bother to even try with them. */ + fstream->no_sendfile = TRUE; +#endif + } else { + if (net_getsockname(fd, NULL, NULL) < 0) + fstream->no_sendfile = TRUE; } return ostream; }
--- a/src/lib/sendfile-util.c Wed Apr 09 23:13:02 2003 +0300 +++ b/src/lib/sendfile-util.c Wed Apr 09 23:28:30 2003 +0300 @@ -92,12 +92,8 @@ i_assert(count <= SSIZE_T_MAX); - /* outfd must be socket, or at least some Solaris versions will + /* NOTE: if outfd is not a socket, some Solaris versions will kernel panic */ - if (net_getsockname(out_fd, NULL, NULL) < 0) { - errno = EINVAL; - return -1; - } vec.sfv_fd = in_fd; vec.sfv_flag = 0;