From: Eric Wong Date: 2011-05-13T05:45:46+09:00 Subject: [ruby-core:36150] [Ruby 1.9 - Bug #4680][Open] [PATCH] io.c: fix busy wait with sendfile() Issue #4680 has been reported by Eric Wong. ---------------------------------------- Bug #4680: [PATCH] io.c: fix busy wait with sendfile() http://redmine.ruby-lang.org/issues/4680 Author: Eric Wong Status: Open Priority: Normal Assignee: Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3dev (2011-05-11 trunk 31521) [x86_64-linux] io.c: fix busy wait with sendfile() When combined with a non-blocking descriptor for sendfile(), select() is used improperly to wait on the writer in the read FD set along with the reader. This causes select() to return immediately if src_fd is a regular file and select() always returns immediately for regular files (at least under Linux). Thus, we need to wait on the writer independently of the reader. Under Linux, we know the reader must must be a regular file if sendfile() is to be used so we avoid waiting on the reader. Test script attached maxes out my CPU. -- http://redmine.ruby-lang.org