This reverts commit 35da41b29b.
This updates `io-console` to avoid accessing the internal details of `rb_io_t`
and instead use `rb_io_descriptor` and `rb_io_path` etc.
Because a thread calling IO#close now blocks in a native condvar wait,
it's possible for there to be _no_ threads left to actually handle
incoming signals/ubf calls/etc.
This manifested as failing tests on Solaris 10 (SPARC), because:
* One thread called IO#close, which sent a SIGVTALRM to the other
thread to interrupt it, and then waited on the condvar to be notified
that the reading thread was done.
* One thread was calling IO#read, but it hadn't yet reached the actual
call to select(2) when the SIGVTALRM arrived, so it never unblocked
itself.
This results in a deadlock.
The fix is to use a real Ruby mutex for the close lock; that way, the
closing thread goes into sigwait-sleep and can keep trying to interrupt
the select(2) thread.
See the discussion in: https://github.com/ruby/ruby/pull/7865/
I cannot find where this is defined. I'm guessing neither this
nor the else branch is ever hit. I only found out when testing
VM changes, which had a bug that exposed this.
https://github.com/ruby/racc/commit/8983d0c134
* Add rb_io_path and rb_io_open_descriptor.
* Use rb_io_open_descriptor to create PTY objects
* Rename FMODE_PREP -> FMODE_EXTERNAL and expose it
FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but
FMODE_EXTERNAL is clearer about what the file descriptor represents and
aligns with language in the IO::Buffer module.
* Ensure that rb_io_open_descriptor closes the FD if it fails
If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be
responsible for closing your file, eventually, if you pass it to
rb_io_open_descriptor, even if it raises an exception.
* Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P
* Expose `rb_io_closed_p`.
* Add `rb_io_mode` to get IO mode.
---------
Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
This commit is to add an extra option to enable verbose mode (V=1) in the
generated `Makefile` at runtime of the Ruby to print compiler command lines by
the commands below when building native extensions. It's possible to enable the
verbose mode by setting the environment variable `MAKEFLAGS="V=1"`[1]
implemented in GNU make. However, I wanted to make a consistent user-interface
not depending on the specific make's implementation.
```
$ ruby /path/to/extconf.rb -- --with-verbose
```
You can also add the extra option via rake-compiler gem.
```
$ rake compiler -- --with-verbose
```
If the extra option is not given, the value of the
`RbConfig::CONFIG["MKMF_VERBOSE"]` enabled by the configure option below is
used.
```
$ ./configure --enable-mkmf-verbose
```
For the unit tests, updated the following files.
* The `test/mkmf/test_configuration.rb` was created to test the cases with the
`configuration` method and this implementation.
* Updated the `TestMkmf#assert_separately` to set the extra
arguments in `test/mkmf/base.rb`. Updated tests using the `assert_separately`.
* Added tests for `MakeMakefile#with_config` in the `test/mkmf/test_config.rb`.
[1] https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html
Fixes [Bug #19695]
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Documentation consistency.
* Improve consistency of `pread`/`pwrite` implementation when given length.
* Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional.