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

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.

Make the PosixShim errno field into a thread-local.
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.

@headius headius added this to the JRuby 9.2.8.0 milestone Apr 25, 2019

@enebo

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

ship it! :)

@headius headius merged commit fd40550 into jruby:master Apr 25, 2019

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
jruby.jruby Build #20190425.1 succeeded
Details

@headius headius deleted the headius: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
Projects
None yet
2 participants
You can’t perform that action at this time.