Skip to content

Commit e41d1d9

Browse files
authored
fix(iroh-gossip): do not drop existing connection on incoming one (#2318)
Fixes #2307
1 parent d813089 commit e41d1d9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

iroh-gossip/src/net.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,13 @@ async fn connection_loop(
615615
loop {
616616
tokio::select! {
617617
biased;
618-
msg = send_rx.recv() => {
619-
match msg {
620-
None => break,
621-
Some(msg) => write_message(&mut send, &mut send_buf, &msg).await?,
622-
}
618+
// If `send_rx` is closed,
619+
// stop selecting it but don't quit.
620+
// We are not going to use connection for sending anymore,
621+
// but the other side may still want to use it to
622+
// send data to us.
623+
Some(msg) = send_rx.recv(), if !send_rx.is_closed() => {
624+
write_message(&mut send, &mut send_buf, &msg).await?
623625
}
624626

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

0 commit comments

Comments
 (0)