fix(remoteingress-core): cancel stale edge connections when an edge reconnects

This commit is contained in:
2026-03-17 12:33:28 +00:00
parent da01fbeecd
commit f9a739858d
3 changed files with 15 additions and 2 deletions

View File

@@ -136,7 +136,7 @@ struct ConnectedEdgeInfo {
peer_addr: String,
edge_stream_count: Arc<AtomicU32>,
config_tx: mpsc::Sender<EdgeConfigUpdate>,
#[allow(dead_code)] // kept alive for Drop — cancels child tokens when edge is removed
/// Used to cancel the old connection when an edge reconnects.
cancel_token: CancellationToken,
}
@@ -677,6 +677,13 @@ async fn handle_edge_connection(
{
let mut edges = connected.lock().await;
// If this edge already has an active connection (reconnect scenario),
// cancel the old connection so it shuts down immediately instead of
// lingering until TCP keepalive detects the dead socket.
if let Some(old) = edges.remove(&edge_id) {
log::info!("Edge {} reconnected, cancelling old connection", edge_id);
old.cancel_token.cancel();
}
edges.insert(
edge_id.clone(),
ConnectedEdgeInfo {