Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(multiplexer): propagate a transport closed error if an unrecoverable error occurs #487

Merged
merged 2 commits into from
Nov 4, 2022
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
8 changes: 8 additions & 0 deletions minidsp/src/transport/multiplexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@ impl Multiplexer {
{
let transport = transport.clone();
let receiver_tx = transport.event_tx.clone();
let pending_commands = transport.pending_command.clone();

tokio::spawn(async move {
let result = transport.recv_loop(recv_send, rx).await;
if let Err(e) = result {
log::error!("recv loop exit: {:?}", e);

// Clear any pending commands by propagating the error
let mut pending = pending_commands.lock().unwrap();
while let Some((_, tx)) = pending.pop_front() {
let _ = tx.send(Err(MiniDSPError::TransportClosed));
}
}
let mut tx = receiver_tx.lock().unwrap();
// Set `receiver_tx` to None to mark this as closed
Expand Down