Skip to content
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

Make the PosixShim errno field into a thread-local #5711

Merged
merged 1 commit into from Apr 25, 2019

Conversation

@headius
Copy link
Member

@headius headius commented Apr 25, 2019

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.

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.
@headius headius added this to the JRuby 9.2.8.0 milestone Apr 25, 2019
@enebo
Copy link
Member

@enebo enebo commented Apr 25, 2019

ship it! :)

Loading

@headius headius merged commit fd40550 into jruby:master Apr 25, 2019
1 of 2 checks passed
Loading
@headius headius deleted the thread_local_posix_shim_errno branch Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants