Issue #17415 has been updated by zverok (Victor Shepelev).


https://docs.ruby-lang.org/en/master/doc/scheduler_md.html#label-IO

> By default, I/O is non-blocking. Not all operating systems support non-blocking I/O. Windows is a notable example where socket I/O can be non-blocking but pipe I/O is blocking.

----------------------------------------
Bug #17415: IO read gets blocked with Fiber Scheduler on Windows
https://bugs.ruby-lang.org/issues/17415#change-89370

* Author: dsh0416 (Delton Ding)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0dev (2020-12-19 master 4735a5b9d2) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Here is the given example code for reproduction the bug:

```ruby
rd, wr = IO.pipe
scheduler = Evt::Scheduler.new # Any scheduler including the test scheduler in the ruby repo could reproduce the same problem.

message = nil
Fiber.set_scheduler scheduler

Fiber.schedule do
  wr.write(MESSAGE)
  wr.close
end
  
Fiber.schedule do
  message = rd.read(20)
  rd.close
end

scheduler.run

assert_equal MESSAGE, message
assert rd.closed?
assert wr.closed?
```

When running under Linux, FreeBSD or macOS, the code works fine. But when running under Windows:

```ruby
#...

Fiber.schedule do
  message = rd.read(20) # !!! -> Got blocked here
  rd.close
end

#...
```

Since some of the files don't support non-blocking on Windows, I double checked with the following code:

```ruby
a, b = IO.pipe
b.write_nonblock("Test")
a.read_nonblock(4) # => "Test"
```

which works totally fine on Windows. I suppose some kind of IO non-blocking setup is not working properly under Windows.

Still investigating the details for patching...




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>