Skip to content

Commit

Permalink
Don't use EPOLLONESHOT for the wakeup event. (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Math2 authored Aug 16, 2023
1 parent 3fc744c commit 2483f4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/io/event/selector/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void IO_Event_Interrupt_add(struct IO_Event_Interrupt *interrupt, struct IO_Even
int descriptor = IO_Event_Interrupt_descriptor(interrupt);

struct epoll_event event = {
.events = EPOLLIN|EPOLLRDHUP|EPOLLONESHOT,
.events = EPOLLIN|EPOLLRDHUP,
.data = {.fd = -1},
};

Expand Down
15 changes: 15 additions & 0 deletions test/io/event/selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ def transfer
thread.join
end

it "can wakeup selector from different thread twice in a row" do
2.times do
thread = Thread.new do
sleep 0.1
selector.wakeup
end

expect do
selector.select(0.5)
end.to have_duration(be < 0.5)
ensure
thread.join
end
end

it "ignores wakeup if not selecting" do
expect(selector.wakeup).to be == false
end
Expand Down

0 comments on commit 2483f4e

Please sign in to comment.