* 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:
parent
e1dc8e0c22
commit
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>
|
Mon Dec 13 09:50:09 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb (Net::HTTPRequest#set_form): Added to support
|
* lib/net/http.rb (Net::HTTPRequest#set_form): Added to support
|
||||||
|
36
io.c
36
io.c
@ -8198,25 +8198,45 @@ nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
|
|||||||
|
|
||||||
#ifdef HAVE_SENDFILE
|
#ifdef HAVE_SENDFILE
|
||||||
|
|
||||||
#ifdef __linux__
|
# ifdef __linux__
|
||||||
#define USE_SENDFILE
|
# define USE_SENDFILE
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SENDFILE_H
|
# ifdef HAVE_SYS_SENDFILE_H
|
||||||
#include <sys/sendfile.h>
|
# include <sys/sendfile.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
static ssize_t
|
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)
|
||||||
{
|
{
|
||||||
#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
|
||||||
return sendfile(out_fd, in_fd, offset, (size_t)count);
|
return sendfile(out_fd, in_fd, offset, (size_t)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
# 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
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user