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

Server.handleCalls: deal with ack/Go correctly when shutting down. #428

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

zenhack
Copy link
Contributor

@zenhack zenhack commented Jan 14, 2023

Previously, the logic to check for an ack after returning from handleCall was missing from the loop that drains the queue after the server's context is canceled. This means that if when draining the queue, if a method handle calls .Go() before checking the context, there will be two goroutines servicing method calls when it returns.

This patch folds the shutdown into the same loop, so that the logic is the same, and so that the shutdown logic respects acks.

Since the queue is meant to be single-consumer, the exact consequences of this are a bit hard to reason about, though I have noticed that after fixing this some of the behavior I had attributed to #423 is less common.

Previously, the logic to check for an ack after returning from
handleCall was missing from the loop that drains the queue after
the server's context is canceled. This means that if when draining the
queue, if a method handle calls .Go() before checking the context,
there will be two goroutines servicing method calls when it returns.

This patch folds the shutdown into the same loop, so that the logic is
the same, and so that the shutdown logic respects acks.

Since the queue is meant to be single-consumer, the exact consequences
of this are a bit hard to reason about, though I have noticed that after
fixing this some of the behavior I had attributed to capnproto#423 is less
common.
@lthibault
Copy link
Collaborator

Oh look! Successful CI 🎉

@lthibault lthibault merged commit 993783d into capnproto:main Jan 14, 2023
@zenhack zenhack deleted the server-shutdown-ack-race branch January 14, 2023 23:08
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