Skip to content

Commit

Permalink
Make single_session restart cancel-safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Jan 31, 2023
1 parent cbf9369 commit 8ffd4ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bluer/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ impl SessionInner {

if let Some((term_tx_weak, termed_rx)) = single_sessions.get_mut(path) {
match term_tx_weak.upgrade() {
Some(term_tx) => return Ok(SingleSessionToken(term_tx)),
Some(term_tx) => {
log::trace!("Using existing single session for {}", &path);
return Ok(SingleSessionToken(term_tx));
}
None => {
log::trace!("Waiting for termination of previous single session for {}", &path);
let _ = termed_rx.await;
single_sessions.remove(path);
}
}
}
Expand All @@ -87,6 +92,7 @@ impl SessionInner {
let path = path.clone();
tokio::spawn(async move {
let _ = term_rx.await;
log::trace!("Terminating single session for {}", &path);
stop_fn.await;
let _ = termed_tx.send(());
log::trace!("Terminated single session for {}", &path);
Expand Down

0 comments on commit 8ffd4ae

Please sign in to comment.