-
Notifications
You must be signed in to change notification settings - Fork 19
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
Handle timeout in the client IO task #1109
Conversation
mut fr: FramedRead<R, crucible_protocol::CrucibleDecoder>, | ||
mut fw: FramedWrite<W, crucible_protocol::CrucibleEncoder>, | ||
log: &Logger, | ||
log: Logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github is butchering the diff here, sorry about that!
I moved the code from within the tokio::spawn
into a separate function named rx_loop
, which now includes the timeout as well as reading from the FramedRead
(so it's got a select!
in there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, thanks for the comment otherwise I would have puzzled about this for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, inside the client task is the right place for this stuff.
mut fr: FramedRead<R, crucible_protocol::CrucibleDecoder>, | ||
mut fw: FramedWrite<W, crucible_protocol::CrucibleEncoder>, | ||
log: &Logger, | ||
log: Logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, thanks for the comment otherwise I would have puzzled about this for a while.
This PR moves the timeout into the client IO task, for consistency with other forms of disconnection.
Previously, the main Upstairs event loop would notice the timeout, then tell the client task to stop; this was a roundabout way of doing things led to stuff like the panic seen in #1103.
For symmetry, we also move the ping task into the client IO task, since there's no reason to bother the main event loop about it: we always want to be pinging periodically, as long as the client IO task is running.