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

Correctly lock fds when closing old listeners #34

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Conversation

euank
Copy link
Collaborator

@euank euank commented Sep 27, 2024

mu is used to protect all reads and writes of the fds map in Fds.

closeUnused is writing to the map, and so needs a lock. Oops :(

The confusing naming of 'lockMutations' made me think this was a leaky abstraction that held the lock between function calls, but it's not that, it's just setting an informational message and 'locked' boolean (also protected by 'mu'), 'mu' itself still needs to be held.

The naming of those methods is clearly confusing since it confused me, but making more drastic changes seems like it's best left to another PR.

`mu` is used to protect all reads and writes of the `fds` map in `Fds`.

`closeUnused` is wriitng to the map, and so needs a lock. Oops :(

The confusing naming of 'lockMutations' made me think this was a leaky
abstraction that held the lock between function calls, but it's not
that, it's just setting an informational message and 'locked' boolean
(also protected by 'mu'), 'mu' itself still needs to be held.

The naming of those methods is clearly confusing since it confused me,
but making more drastic changes seems like it's best left to another PR.
@euank euank merged commit 7f6ed0d into main Sep 27, 2024
2 checks passed
@euank euank deleted the euan/close-race branch September 27, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants