-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix: opening/reading from fifo/chardev files are blocking the thread #14255
Merged
straight-shoota
merged 7 commits into
crystal-lang:master
from
ysbaddaden:fix/8152/fifo-and-chardev-files-must-be-nonblocking
Feb 21, 2024
Merged
Fix: opening/reading from fifo/chardev files are blocking the thread #14255
straight-shoota
merged 7 commits into
crystal-lang:master
from
ysbaddaden:fix/8152/fifo-and-chardev-files-must-be-nonblocking
Feb 21, 2024
Commits on Jan 26, 2024
-
Fix: opening/reading from fifo/chardev files are blocking the thread
Disk files are always opened in a blocking way because epoll (for instance) will always say that a file is ready for reach or write. But this is only for regular disk files, and that doesn't apply to pipes and characters devices for example. Opening `/dev/tty` (a character device) will block the current thread when trying to read from it until you start typing on the keyboard. IO::FileDescriptor was taking care to check the file type, but File always told it to be blocking. Worse, trying to open a fifo/pipe file will block the current thread until another thread or process also opens it, which means that we must determine whether to block _before_ trying to open a file (not change it afterwards). I also added a `blocking` parameter to `File.open` and `File.new`.
Configuration menu - View commit details
-
Copy full SHA for 44a1b5e - Browse repository at this point
Copy the full SHA 44a1b5eView commit details -
Configuration menu - View commit details
-
Copy full SHA for f209e08 - Browse repository at this point
Copy the full SHA f209e08View commit details
Commits on Jan 29, 2024
-
Require explicit blocking parameter to File
Removes the automatic detection of the file type and blocking behavior before opening the file as we must support at least EINTR and ENXIO return values for `open(2)`. Blocking still defaults to true. Developers may pass nil for auto detection or false to force the nonblocking flag (after open). Opening a fifo without another thread/process also trying to open for read or write will still block the current thread (will be another PR).
Configuration menu - View commit details
-
Copy full SHA for 46146a5 - Browse repository at this point
Copy the full SHA 46146a5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 23d99d8 - Browse repository at this point
Copy the full SHA 23d99d8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5cd6e7a - Browse repository at this point
Copy the full SHA 5cd6e7aView commit details
Commits on Feb 6, 2024
-
Fix: don't run thread specs with the interpreter
Starting threads very likely requires support from the interpreter to create the thread (so it knows about it) to run the interpreted code in. This also fixes the "can't resume running fiber" exceptions that started appearing in the wait group pull request, because they were always run after the thread related specs.
Configuration menu - View commit details
-
Copy full SHA for 60cef61 - Browse repository at this point
Copy the full SHA 60cef61View commit details -
Configuration menu - View commit details
-
Copy full SHA for a5d8f64 - Browse repository at this point
Copy the full SHA a5d8f64View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.