зеркало из https://github.com/github/ruby.git
* io.c (simple_sendfile): added for BSD version of sendfile(2).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e1dc8e0c22
Коммит
b36c91b6b5
|
@ -1,3 +1,7 @@
|
|||
Mon Dec 13 11:21:14 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* io.c (simple_sendfile): added for BSD version of sendfile(2).
|
||||
|
||||
Mon Dec 13 09:50:09 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* lib/net/http.rb (Net::HTTPRequest#set_form): Added to support
|
||||
|
|
20
io.c
20
io.c
|
@ -8216,6 +8216,26 @@ 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__) || defined(__APPLE__)
|
||||
# ifdef HAVE_SYS_UIO_H
|
||||
# include <sys/uio.h>
|
||||
# endif
|
||||
|
||||
static ssize_t
|
||||
simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
|
||||
{
|
||||
int r;
|
||||
size_t sbytes;
|
||||
# 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);
|
||||
if (r != 0) return -1;
|
||||
return (ssize_t)sbytes;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче