Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(iroh-gossip): do not drop existing peer connection when we get incoming one #2308

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 14 additions & 1 deletion iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,22 @@ impl Actor {

// Spawn a task for this connection
let in_event_tx = self.in_event_tx.clone();

// Clone send_tx and give it to the connection loop
// to prevent the channel from closing.
// Otherwise connection loop will exit as soon as we drop send_tx
// from conn_send_tx map.
//
// We don't want to exit connection loop
// and close the connection just because we don't want to
// use the connection for sending anymore, because the other side
// may still want to use the connection to send data to us.
let send_tx_clone = send_tx.clone();

tokio::spawn(
async move {
debug!("connection established");
match connection_loop(peer_id, conn, origin, send_rx, &in_event_tx).await {
match connection_loop(peer_id, conn, origin, send_tx_clone, send_rx, &in_event_tx).await {
Ok(()) => {
debug!("connection closed without error")
}
Expand Down Expand Up @@ -607,6 +619,7 @@ async fn connection_loop(
from: PublicKey,
conn: Connection,
origin: ConnOrigin,
_send_tx: mpsc::Sender<ProtoMessage>,
mut send_rx: mpsc::Receiver<ProtoMessage>,
in_event_tx: &mpsc::Sender<InEvent>,
) -> anyhow::Result<()> {
Expand Down