diff --git a/miner-apps/jd-client/src/lib/channel_manager/mod.rs b/miner-apps/jd-client/src/lib/channel_manager/mod.rs index 76b7b3e2f..f7f0d477d 100644 --- a/miner-apps/jd-client/src/lib/channel_manager/mod.rs +++ b/miner-apps/jd-client/src/lib/channel_manager/mod.rs @@ -476,6 +476,10 @@ impl ChannelManager { })?; let task_manager_clone = task_manager.clone(); + // Register the listener task in fallback coordination, so fallback waits + // for this accept loop to stop before attempting to re-bind the same port. + let fallback_handler = fallback_coordinator.register(); + let fallback_token = fallback_coordinator.token(); task_manager.spawn(async move { loop { select! { @@ -483,6 +487,10 @@ impl ChannelManager { info!("Downstream Server: received shutdown signal"); break; } + _ = fallback_token.cancelled() => { + info!("Downstream Server: received fallback signal"); + break; + } res = server.accept() => { match res { Ok((stream, socket_address)) => { @@ -568,6 +576,7 @@ impl ChannelManager { } } info!("Downstream server: Unified loop break"); + fallback_handler.done(); }); Ok(()) }