Project

General

Profile

Bug #4680

[PATCH] io.c: fix busy wait with sendfile()

Added by normalperson (Eric Wong) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.3dev (2011-05-11 trunk 31521) [x86_64-linux]
[ruby-core:36150]

Description

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.

0001-io.c-fix-busy-wait-with-sendfile.patch (2.82 KB) 0001-io.c-fix-busy-wait-with-sendfile.patch normalperson (Eric Wong), 05/13/2011 05:45 AM
copy_stream_false_select.rb (456 Bytes) copy_stream_false_select.rb normalperson (Eric Wong), 05/13/2011 05:45 AM

Related issues

Related to Ruby trunk - Bug #4683: [PATCH] io.c: copy_stream execute interrupts and retryClosed2011-05-13

History

#1 [ruby-core:36152] Updated by normalperson (Eric Wong) over 6 years ago

Eric Wong normalperson@yhbt.net wrote:

Test script attached maxes out my CPU.

And with this I also noticed signals aren't handled gracefully
with IO.copy_stream. Fixing now.

--
Eric Wong

#2 [ruby-core:36157] Updated by normalperson (Eric Wong) over 6 years ago

Eric Wong normalperson@yhbt.net wrote:

Eric Wong normalperson@yhbt.net wrote:

Test script attached maxes out my CPU.

And with this I also noticed signals aren't handled gracefully
with IO.copy_stream. Fixing now.

Reported separately: http://redmine.ruby-lang.org/issues/4683

--
Eric Wong

#3 [ruby-core:36549] Updated by naruse (Yui NARUSE) over 6 years ago

  • Status changed from Open to Assigned
  • Assignee set to akr (Akira Tanaka)

#4 [ruby-core:37121] Updated by akr (Akira Tanaka) over 6 years ago

  • Status changed from Assigned to Closed

Also available in: Atom PDF