Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't enable io_write hook on Ruby < 3.3.1 as it's buggy. #303

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- os: ubuntu
ruby: "3.3"
selector: URing
- os: ubuntu
ruby: "head"
selector: URing

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def io_read(io, buffer, length, offset = 0)
timer&.cancel
end

if RUBY_ENGINE != "ruby" || RUBY_VERSION >= "3.3.0"
if RUBY_ENGINE != "ruby" || RUBY_VERSION >= "3.3.1"
def io_write(io, buffer, length, offset = 0)
fiber = Fiber.current

Expand Down
14 changes: 14 additions & 0 deletions test/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,18 @@
expect(input.wait_readable(0)).to be_nil
end
end

describe '/dev/null' do
# Ruby < 3.3.1 will fail this test with the `io_write` scheduler hook enabled, as it will try to io_wait on /dev/null which will fail on some platforms (kqueue).
it "can write to /dev/null" do
out = File.open("/dev/null", "w")

# Needs to write about 8,192 bytes to trigger the internal flush:
1000.times do
out.puts "Hello World!"
end
ensure
out.close
end
end
end
Loading