summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-13 12:28:09 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-13 12:28:09 +0000
commit903538cbb348d51bda9e439770dc6f2777f15c52 (patch)
treeab9fd0e3d19c6e7a657dba4cfc712dadd611c120 /io.c
parent7d481b5423de7312f3fe0f79539fbe342d69dae8 (diff)
* io.c (simple_sendfile): disable the use of sendfile(2) on
FreeBSD. It blocks on TestIO#test_copy_stream_socket. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/io.c b/io.c
index 30767af695..73579dd685 100644
--- a/io.c
+++ b/io.c
@@ -8216,7 +8216,8 @@ simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
return sendfile(out_fd, in_fd, offset, (size_t)count);
}
-# elif defined(__FreeBSD__) || defined(__DragonFly__)
+# elif 0 /* defined(__FreeBSD__) || defined(__DragonFly__) */
+/* at least FreeBSD 8.1 + r30193, sendfiles blocks its execution... */
# define USE_SENDFILE
# ifdef HAVE_SYS_UIO_H
@@ -8227,14 +8228,16 @@ static ssize_t
simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
{
int r;
- size_t sbytes;
+ off_t sbytes;
+ struct sf_hdtr hdtr = {NULL, 0, NULL, 0};
# if SIZEOF_OFF_T > SIZEOF_SIZE_T
/* we are limited by the 32-bit ssize_t return value on 32-bit */
if (count > (off_t)SSIZE_MAX)
count = SSIZE_MAX;
# endif
- r = sendfile(in_fd, out_fd, *offset, (size_t)count, NULL, &sbytes, 0);
+ r = sendfile(in_fd, out_fd, offset ? *offset : 0, (size_t)count, &hdtr, &sbytes, SF_NODISKIO);
if (r != 0) return -1;
+ if (offset) *offset = sbytes;
return (ssize_t)sbytes;
}