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

Ignore client messages after stopping the IO task #1126

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions upstairs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,21 @@ impl DownstairsClient {
/// must the select expressions be cancel safe, but the **bodies** must also
/// be cancel-safe. This is why we simply return a single value in the body
/// of each statement.
///
/// This function will wait forever if we have asked for the client task to
/// stop, so it should only be called in a higher-level `select!`.
pub(crate) async fn select(&mut self) -> ClientAction {
tokio::select! {
d = self.client_task.client_response_rx.recv() => {
match d {
Some(c) => c.into(),
None => ClientAction::ChannelClosed,
}
loop {
let out = match self.client_task.client_response_rx.recv().await {
Some(c) => c.into(),
None => break ClientAction::ChannelClosed,
};
// Ignore client responses if we have told the client to exit (we
// still propagate other ClientAction variants, e.g. TaskStopped).
if self.client_task.client_stop_tx.is_some()
|| !matches!(out, ClientAction::Response(..))
{
break out;
}
}
}
Expand Down
Loading