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 19, 2024
1 parent 26405a4 commit 24a9c2f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,20 @@ async fn connection_loop(
};
let mut send_buf = BytesMut::new();
let mut recv_buf = BytesMut::new();
let mut tx_open = true;
loop {
tokio::select! {
biased;
msg = send_rx.recv() => {
msg = send_rx.recv(), if tx_open => {
match msg {
None => break,
None => {
// Channel is closed and is always ready to return None now,
// stop polling it.
// We are not going to use the connection for sending anymore,
// but do not exit yet because the other side may
// still want to use the connection to send data to us.
tx_open = false;
}
Some(msg) => write_message(&mut send, &mut send_buf, &msg).await?,
}
}
Expand Down

0 comments on commit 24a9c2f

Please sign in to comment.