diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-12 02:18:51 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-12 02:18:51 +0000 |
commit | 60e078c860eed4ed92aa7be556623a52bf218f1b (patch) | |
tree | c72ef47047128d7dff90cfbeea85a3eba077d313 /io.c | |
parent | df3e3768e98b6bc60e8f0297c80ad7d8696e6a1e (diff) |
* io.c: use select() appropriately for sendfile().
Fixed by Eric Wong. [ruby-core:36150]
(maygvl_copy_stream_wait_readwrite): removed.
(nogvl_copy_stream_sendfile): use nogvl_copy_stream_wait_write and
maygvl_copy_stream_wait_read instead of
maygvl_copy_stream_wait_readwrite.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -8649,22 +8649,6 @@ simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count) #ifdef USE_SENDFILE static int -maygvl_copy_stream_wait_readwrite(int has_gvl, struct copy_stream_struct *stp) -{ - int ret; - rb_fd_zero(&stp->fds); - rb_fd_set(stp->src_fd, &stp->fds); - rb_fd_set(stp->dst_fd, &stp->fds); - ret = maygvl_select(has_gvl, rb_fd_max(&stp->fds), &stp->fds, NULL, NULL, NULL); - if (ret == -1) { - stp->syserr = "select"; - stp->error_no = errno; - return -1; - } - return 0; -} - -static int nogvl_copy_stream_sendfile(struct copy_stream_struct *stp) { struct stat src_stat, dst_stat; @@ -8746,7 +8730,18 @@ nogvl_copy_stream_sendfile(struct copy_stream_struct *stp) #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif - if (maygvl_copy_stream_wait_readwrite(0, stp) == -1) +#ifndef linux + /* + * Linux requires stp->src_fd to be a mmap-able (regular) file, + * select() reports regular files to always be "ready", so + * there is no need to select() on it. + * Other OSes may have the same limitation for sendfile() which + * allow us to bypass maygvl_copy_stream_wait_read()... + */ + if (maygvl_copy_stream_wait_read(0, stp) == -1) + return -1; +#endif + if (nogvl_copy_stream_wait_write(stp) == -1) return -1; goto retry_sendfile; } |