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

Clean up locking in Conn.shutdown() #398

Merged
merged 2 commits into from
Dec 27, 2022
Merged

Conversation

zenhack
Copy link
Contributor

@zenhack zenhack commented Dec 26, 2022

This patch changes the contract of shutdown() such that it now expects the caller not to be holding c.lk. This allows it to acquire and release the lock itself as needed, thereby avoiding the need for syncutil.Without or just plain unlock/lock pairs.

This also reworks its subroutines to avoid unlock/lock pairs. The result is a lot easier to follow imo.


There is now only one use of syncutil.Without left in the codebase, though there are likely several other logical unlock/lock pairs to be rooted out.

...rather than having the caller do it. This is step 1 in cleaning up
the logic here.
...including in subroutines. IMO the shutdown logic is a lot clearer
after this change.
@zenhack
Copy link
Contributor Author

zenhack commented Dec 26, 2022

Failure looks like #394, re-running.

Copy link
Collaborator

@lthibault lthibault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is much cleaner 👍

@zenhack zenhack merged commit bd7e3f0 into capnproto:main Dec 27, 2022
@zenhack zenhack deleted the shutdown-locking branch December 27, 2022 03:19
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