Skip to content

Commit

Permalink
Merge pull request #4486 from headius/fix-ewouldblock-waitreadable
Browse files Browse the repository at this point in the history
Set up EWOULDBLOCKWaitReadable/Writable if not present. Fix #4473
  • Loading branch information
headius committed Feb 13, 2017
2 parents 675adb2 + 8bd3949 commit 164cded
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/ruby/jruby/kernel/io.rb
Expand Up @@ -7,6 +7,19 @@ class EAGAINWaitWritable < Errno::EAGAIN
include IO::WaitWritable
end

if Errno::EAGAIN == Errno::EWOULDBLOCK
IO::EWOULDBLOCKWaitReadable = IO::EAGAINWaitReadable
IO::EWOULDBLOCKWaitWritable = IO::EAGAINWaitWritable
else
class EWOULDBLOCKWaitReadable < Errno::EWOULDBLOCK
include IO::WaitReadable
end

class EWOULDBLOCKWaitWritable < Errno::EWOULDBLOCK
include IO::WaitWritable
end
end

class EINPROGRESSWaitWritable < Errno::EINPROGRESS
include IO::WaitWritable
end
Expand Down
44 changes: 44 additions & 0 deletions spec/ruby/core/exception/io_error_spec.rb
Expand Up @@ -5,3 +5,47 @@
IOError.should be_ancestor_of(EOFError)
end
end

describe "IO::EAGAINWaitReadable" do
it "combines Errno::EAGAIN and IO::WaitReadable" do
IO::EAGAINWaitReadable.superclass.should == Errno::EAGAIN
IO::EAGAINWaitReadable.ancestors.should include IO::WaitReadable
end

it "is the same as IO::EWOULDBLOCKWaitReadable if Errno::EAGAIN is the same as Errno::EWOULDBLOCK" do
if Errno::EAGAIN.equal? Errno::EWOULDBLOCK
IO::EAGAINWaitReadable.should equal IO::EWOULDBLOCKWaitReadable
else
IO::EAGAINWaitReadable.should_not equal IO::EWOULDBLOCKWaitReadable
end
end
end

describe "IO::EWOULDBLOCKWaitReadable" do
it "combines Errno::EWOULDBLOCK and IO::WaitReadable" do
IO::EWOULDBLOCKWaitReadable.superclass.should == Errno::EWOULDBLOCK
IO::EAGAINWaitReadable.ancestors.should include IO::WaitReadable
end
end

describe "IO::EAGAINWaitWritable" do
it "combines Errno::EAGAIN and IO::WaitWritable" do
IO::EAGAINWaitWritable.superclass.should == Errno::EAGAIN
IO::EAGAINWaitWritable.ancestors.should include IO::WaitWritable
end

it "is the same as IO::EWOULDBLOCKWaitWritable if Errno::EAGAIN is the same as Errno::EWOULDBLOCK" do
if Errno::EAGAIN.equal? Errno::EWOULDBLOCK
IO::EAGAINWaitWritable.should equal IO::EWOULDBLOCKWaitWritable
else
IO::EAGAINWaitWritable.should_not equal IO::EWOULDBLOCKWaitWritable
end
end
end

describe "IO::EWOULDBLOCKWaitWritable" do
it "combines Errno::EWOULDBLOCK and IO::WaitWritable" do
IO::EWOULDBLOCKWaitWritable.superclass.should == Errno::EWOULDBLOCK
IO::EAGAINWaitWritable.ancestors.should include IO::WaitWritable
end
end

0 comments on commit 164cded

Please sign in to comment.