Make the PosixShim errno field into a thread-local#5711
Merged
headius merged 1 commit intojruby:masterfrom Apr 25, 2019
Merged
Conversation
In order to support concurrent reads and writes via the PosixShim, we need to make errno be a thread-local. Some callers do their own locking, releasing the lock before calling PosixShim, which causes the errno updates and clears to step on other threads. It might be possible to have those callers pass in their "unlock around" logic as shown in jruby#5706, but my first attempt did not work exactly right and may introduces object overhead for stateful lambdas. This implementation introduces thread-local read/write overhead to all accessors of errno, but appears to be a clean way to keep this field safe across concurrent IO operations. Fixes jruby#5706.
Member
|
ship it! :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In order to support concurrent reads and writes via the PosixShim,
we need to make errno be a thread-local. Some callers do their own
locking, releasing the lock before calling PosixShim, which causes
the errno updates and clears to step on other threads. It might be
possible to have those callers pass in their "unlock around" logic
as shown in #5706, but my first attempt did not work exactly right
and may introduces object overhead for stateful lambdas.
This implementation introduces thread-local read/write overhead to
all accessors of errno, but appears to be a clean way to keep this
field safe across concurrent IO operations.
Fixes #5706.