Clean up/fix locking in handleReturn #395
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This cleans up/fixes some of the locking towards the end of handleReturn; previously this was super convoluted, in part because we'd just put the whole rest of the function in a giant
go func() {...}()
at some point to solve a deadlock without cleaning it up in a more structural way; see the now-deletedTODO(cleanup)
.This also adds a few comments related to the reasoning behind some conditionals, which are a bit obtuse. I think this probably could be cleaned up further, but this maintains the existing behavior while documenting it a bit better at least.
Finally, while doing the above I noticed that sendMessage() was being called without holding c.lk, so I added a call to syncutil.With to fix that.
After this patch there are only three remaining calls to
syncutil.Without
in the rpc package.