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

IO: Set fd to -1 on closed File/Socket #8873

Merged
merged 4 commits into from
Mar 8, 2020
Merged

Conversation

bcardiff
Copy link
Member

@bcardiff bcardiff commented Mar 2, 2020

Based on #8733 (comment)

When closing a File or Socket the fd is set to -1 to force an invalid file descriptor on other threads that passed the check_open assertion before closing it.

Atomic is used to force a volatile Java-like semantics so the reads are sequentially consistent with the writes of other threads.

@bcardiff bcardiff added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:files topic:stdlib:networking topic:multithreading labels Mar 2, 2020
bcardiff added 3 commits March 2, 2020 15:04
This is to reduce the chance of reading an outdated fd value
This will force a volatile semantic over the value and prevent using an outdated value across multiple threads.
@bcardiff bcardiff requested a review from RX14 March 2, 2020 18:05
@bcardiff bcardiff added this to the 0.34.0 milestone Mar 5, 2020
@RX14 RX14 merged commit f97b6b6 into crystal-lang:master Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:multithreading topic:stdlib:files topic:stdlib:networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants