Skip to content

Commit

Permalink
fix(iroh-gossip): do not drop existing peer connection when we get in…
Browse files Browse the repository at this point in the history
…coming one
  • Loading branch information
link2xt committed May 22, 2024
1 parent d813089 commit e12b909
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,13 @@ async fn connection_loop(
loop {
tokio::select! {
biased;
msg = send_rx.recv() => {
match msg {
None => break,
Some(msg) => write_message(&mut send, &mut send_buf, &msg).await?,
}
// If `send_rx` is closed,
// stop selecting it but don't quit.
// We are not going to use connection for sending anymore,
// but the other side may still want to use it to
// send data to us.
Some(msg) = send_rx.recv(), if !send_rx.is_closed() => {
write_message(&mut send, &mut send_buf, &msg).await?
}

msg = read_message(&mut recv, &mut recv_buf) => {
Expand Down

0 comments on commit e12b909

Please sign in to comment.