| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
* Documentation consistency.
* Improve consistency of `pread`/`pwrite` implementation when given length.
* Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When one thread is closing a file descriptor whilst another thread is
concurrently reading it, we need to wait for the reading thread to be
done with it to prevent a potential EBADF (or, worse, file descriptor
reuse).
At the moment, that is done by keeping a list of threads still using the
file descriptor in io_close_fptr. It then continually calls
rb_thread_schedule() in fptr_finalize_flush until said list is empty.
That busy-looping seems to behave rather poorly on some OS's,
particulary FreeBSD. It can cause the TestIO#test_race_gets_and_close
test to fail (even with its very long 200 second timeout) because the
closing thread starves out the using thread.
To fix that, I introduce the concept of struct rb_io_close_wait_list; a
list of threads still using a file descriptor that we want to close. We
call `rb_notify_fd_close` to let the thread scheduler know we're closing
a FD, which fills the list with threads. Then, we call
rb_notify_fd_close_wait which will block the thread until all of the
still-using threads are done.
This is implemented with a condition variable sleep, so no busy-looping
is required.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
|
|
|
| |
* Skip test if non-blocking file IO is not supported.
|
|
|
|
| |
Fixes [Bug #19380]
|
|
|
| |
Mention that autoclose changes the behavior of explicit close in addition to implicit close at IO finalization.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was already the behavior when a single `'external:internal'`
encoding specifier string was passed. This makes the behavior
consistent for the case where separate external and internal
encoding specifiers are provided.
While here, fix the IO#set_encoding method documentation to
state that either the first or second argument can be a string
with an encoding name, and describe the behavior when the
external encoding is binary.
Fixes [Bug #18899]
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
When `maxlen` is `nil`, it uses the data mode of the stream.
For example in the following:
```ruby
File.binwrite("a.txt", "\r\n\r")
p File.open("a.txt", "rt").read # "\n\n"
p File.open("a.txt", "rt").read(3) # "\r\n\r"
```
Note, this newline translation is _not_ specific to Windows.
|
| |
|
|
|
|
|
|
|
|
| |
[Feature #6047]
Currently it's grown by `BUFSIZ` (1024) on every iteration which is bit wasteful.
Instead we can double the capacity whenever there is less than `BUFSIZ` capacity
left.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
In io.c treats:
#close
#close_read
#close_write
#closed
|
| |
|
|
|
|
| |
(#6559)
|
| |
|
| |
|
| |
|
| |
|
|
|
| |
Integrate io_streams.rdoc into io.c
|
|
|
|
|
|
| |
Moves Expect library doc into io.c.
Changes certain links to local sections, now pointing to sections in doc/io_streams.rdoc.
Removes local sections now superseded by sections in doc/io_streams.rdoc.
|
| |
|
|
|
|
|
|
| |
Raise `ArgumentError` in `IO#sysread` on Windows when given a negative
length.
Fixes [Bug #18880]
|
|
|
|
| |
Get rid of the conflict with system-provided small `off_t`.
|
|
|
|
|
|
| |
Makes behavior consistent with IO.readlines.
Fixes [Bug #18767]
|
|
|
|
|
|
|
|
|
| |
I don't think this is super well known so it's worth mentioning as it
can be a pitfall.
See: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
|
|
|
|
| |
See: https://bugs.ruby-lang.org/issues/18882#note-13
[Bug #18882]
|
| |
|
|
|
|
|
|
|
| |
The value affects the name of the backup file created, not the
name of the file modified (as the file is modified in place).
Fixes [Bug #18920]
|
| |
|
|
|
|
| |
Use IO#eof? instead of I#eof?
|
|
|
|
|
|
|
| |
nil separator means no sepator, so chomp should not remove a line
separator.
Partially Fixes [Bug #18770]
|
|
|
|
| |
[Misc #18891]
|
|
|
|
|
|
|
|
| |
chomp"
This reverts commit 04f86ad0b5d2fe4711ff300d855228a6aed55f33.
This is causing CI issues, reverting for now.
|
|
|
|
|
|
|
| |
nil separator means no sepator, so chomp should not remove a line
separator.
Partially Fixes [Bug #18770]
|
|
|
|
| |
[Bug #18909]
|
| |
|