* io.c (simple_sendfile): improve linux compatibility on FreeBSD,
and now it works. But without cpuset -l 0, it still gets stuck. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8c757a3268
commit
bdd3f75598
@ -1,3 +1,8 @@
|
|||||||
|
Tue Dec 14 23:53:52 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (simple_sendfile): improve linux compatibility on FreeBSD,
|
||||||
|
and now it works. But without cpuset -l 0, it still gets stuck.
|
||||||
|
|
||||||
Tue Dec 14 20:31:33 2010 Tanaka Akira <akr@fsij.org>
|
Tue Dec 14 20:31:33 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* gc.c: parenthesize macro arguments.
|
* gc.c: parenthesize macro arguments.
|
||||||
|
17
io.c
17
io.c
@ -8217,7 +8217,9 @@ simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# elif 0 /* defined(__FreeBSD__) || defined(__DragonFly__) */
|
# elif 0 /* defined(__FreeBSD__) || defined(__DragonFly__) */
|
||||||
/* at least FreeBSD 8.1 + r30193, sendfiles blocks its execution... */
|
/* This runs on FreeBSD8.1 r30210, but sendfiles blocks its execution
|
||||||
|
* without cpuset -l 0.
|
||||||
|
*/
|
||||||
# define USE_SENDFILE
|
# define USE_SENDFILE
|
||||||
|
|
||||||
# ifdef HAVE_SYS_UIO_H
|
# ifdef HAVE_SYS_UIO_H
|
||||||
@ -8228,16 +8230,21 @@ static ssize_t
|
|||||||
simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
|
simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
off_t pos = offset ? *offset : lseek(in_fd, 0, SEEK_CUR);
|
||||||
off_t sbytes;
|
off_t sbytes;
|
||||||
struct sf_hdtr hdtr = {NULL, 0, NULL, 0};
|
|
||||||
# if SIZEOF_OFF_T > SIZEOF_SIZE_T
|
# if SIZEOF_OFF_T > SIZEOF_SIZE_T
|
||||||
/* we are limited by the 32-bit ssize_t return value on 32-bit */
|
/* we are limited by the 32-bit ssize_t return value on 32-bit */
|
||||||
if (count > (off_t)SSIZE_MAX)
|
if (count > (off_t)SSIZE_MAX)
|
||||||
count = SSIZE_MAX;
|
count = SSIZE_MAX;
|
||||||
# endif
|
# endif
|
||||||
r = sendfile(in_fd, out_fd, offset ? *offset : 0, (size_t)count, &hdtr, &sbytes, SF_NODISKIO);
|
r = sendfile(in_fd, out_fd, pos, (size_t)count, NULL, &sbytes, 0);
|
||||||
if (r != 0) return -1;
|
if (offset) {
|
||||||
if (offset) *offset = sbytes;
|
*offset += sbytes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lseek(in_fd, sbytes, SEEK_CUR);
|
||||||
|
}
|
||||||
|
if (r != 0 && sbytes == 0) return -1;
|
||||||
return (ssize_t)sbytes;
|
return (ssize_t)sbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user