Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5c5905c55103
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9a852dd4399a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 30, 2015

  1. Copy the full SHA
    5097d35 View commit details
  2. Copy the full SHA
    9a852dd View commit details
Showing with 13 additions and 11 deletions.
  1. +12 −11 kernel/common/io.rb
  2. +1 −0 kernel/platform/posix.rb
23 changes: 12 additions & 11 deletions kernel/common/io.rb
Original file line number Diff line number Diff line change
@@ -655,8 +655,9 @@ def self.fd_set_from_array(array)
highest = -1
fd_set = FDSet.new
fd_set.zero

array.each do |io|
io = io[1] if io.is_a?(Array)
descriptor = io.descriptor

if descriptor >= MAX_FD
@@ -682,10 +683,10 @@ def self.reset_timeout(limit, now)
end

def self.select(readables, writables, errorables, timeout)
read_set, highest_read_fd = fd_set_from_array(readables)
write_set, highest_write_fd = fd_set_from_array(writables)
error_set, highest_err_fd = fd_set_from_array(errorables)
max_fd = [highest_read_fd, highest_write_fd, highest_err_fd].max
read_set, highest_read_fd = readables.nil? ? [nil, nil] : fd_set_from_array(readables)
write_set, highest_write_fd = writables.nil? ? [nil, nil] : fd_set_from_array(writables)
error_set, highest_err_fd = errorables.nil? ? [nil, nil] : fd_set_from_array(errorables)
max_fd = [highest_read_fd, highest_write_fd, highest_err_fd].compact.max

time_limit, now = make_timeval_timeout(timeout)

@@ -1338,13 +1339,13 @@ def self.select(readables=nil, writables=nil, errorables=nil, timeout=nil)

if readables
readables =
Rubinius::Type.coerce_to(readables, Array, :to_ary).map do |obj|
readables.to_ary.map do |obj|
if obj.kind_of? IO
raise IOError, "closed stream" if obj.closed?
return [[obj],[],[]] unless obj.buffer_empty? # FIXME: eliminated buffer_empty? so what do we check here?
obj
else
io = Rubinius::Type.coerce_to(obj, IO, :to_io)
io = obj.to_io
raise IOError, "closed stream" if io.closed?
[obj, io]
end
@@ -1353,12 +1354,12 @@ def self.select(readables=nil, writables=nil, errorables=nil, timeout=nil)

if writables
writables =
Rubinius::Type.coerce_to(writables, Array, :to_ary).map do |obj|
writables.to_ary.map do |obj|
if obj.kind_of? IO
raise IOError, "closed stream" if obj.closed?
obj
else
io = Rubinius::Type.coerce_to(obj, IO, :to_io)
io = obj.to_io
raise IOError, "closed stream" if io.closed?
[obj, io]
end
@@ -1367,12 +1368,12 @@ def self.select(readables=nil, writables=nil, errorables=nil, timeout=nil)

if errorables
errorables =
Rubinius::Type.coerce_to(errorables, Array, :to_ary).map do |obj|
errorables.to_ary.map do |obj|
if obj.kind_of? IO
raise IOError, "closed stream" if obj.closed?
obj
else
io = Rubinius::Type.coerce_to(obj, IO, :to_io)
io = obj.to_io
raise IOError, "closed stream" if io.closed?
[obj, io]
end
1 change: 1 addition & 0 deletions kernel/platform/posix.rb
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ module FFI::Platform::POSIX
attach_function :ftruncate, [:int, :off_t], :int
attach_function :truncate, [:string, :off_t], :int
attach_function :write, [:int, :pointer, :size_t], :ssize_t
attach_function :select, [:int, :ulong_long, :ulong_long, :ulong_long, :pointer], :int

# Other I/O
attach_function :pipe, [:pointer], :int