* 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
This commit is contained in:
akr 2011-06-12 02:18:51 +00:00
Родитель df3e3768e9
Коммит 60e078c860
2 изменённых файлов: 21 добавлений и 17 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Sun Jun 12 11:16:59 2011 Tanaka Akira <akr@fsij.org>
* 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.
Sun Jun 12 09:32:13 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* atomic.h (ATOMIC_OR): _InterlockedOr is not available on migw.

29
io.c
Просмотреть файл

@ -8648,22 +8648,6 @@ simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
#endif
#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)
{
@ -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;
}