ruby-changes:19972
From: akr <ko1@a...>
Date: Sun, 12 Jun 2011 11:19:03 +0900 (JST)
Subject: [ruby-changes:19972] akr:r32019 (trunk): * io.c: use select() appropriately for sendfile().
akr 2011-06-12 11:18:51 +0900 (Sun, 12 Jun 2011) New Revision: 32019 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32019 Log: * 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. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 32018) +++ ChangeLog (revision 32019) @@ -1,3 +1,12 @@ +Sun Jun 12 11:16:59 2011 Tanaka Akira <akr@f...> + + * 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@r...> * atomic.h (ATOMIC_OR): _InterlockedOr is not available on migw. Index: io.c =================================================================== --- io.c (revision 32018) +++ io.c (revision 32019) @@ -8649,22 +8649,6 @@ #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,8 +8730,19 @@ #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; } stp->syserr = "sendfile"; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/