Skip to content

Commit

Permalink
Failing test case for waiting on a reused FD.
Browse files Browse the repository at this point in the history
  • Loading branch information
Math2 authored and ioquatix committed Aug 16, 2023
1 parent 2483f4e commit 32aa01e
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions test/io/event/selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,68 @@ def transfer
]
end

it "can wait consecutively on two different io objects that share a fd" do
fiber = Fiber.new do
events << :write1
remote.puts "Hello World"

events << :wait_readable1

expect(
selector.io_wait(Fiber.current, local, IO::READABLE)
).to be == IO::READABLE

events << :readable1

events << :new_io
fileno = local.fileno
local.close
new_local, new_remote = UNIXSocket.pair
# Make sure we attempt to wait on the same FD.
if new_remote.fileno == fileno
new_local, new_remote = new_remote, new_local
end
if new_local.fileno != fileno
warn "Could not create new IO object with same FD, test ineffective!"
end

events << :write2
new_remote.puts "Hello World"

events << :wait_readable2

expect(
selector.io_wait(Fiber.current, new_local, IO::READABLE)
).to be == IO::READABLE

events << :readable2
end

events << :transfer
fiber.transfer

events << :select1

selector.select(1)

events << :select2

selector.select(1)

expect(events).to be == [
:transfer,
:write1,
:wait_readable1,
:select1,
:readable1,
:new_io,
:write2,
:wait_readable2,
:select2,
:readable2,
]
end

it "can handle exception during wait" do
fiber = Fiber.new do
events << :wait_readable
Expand Down

0 comments on commit 32aa01e

Please sign in to comment.