@@ -322,7 +322,7 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> { |
| 322 | 322 | |
| 323 | 323 | // Cooldown after control returns to prevent immediate bounce-back |
| 324 | 324 | let mut last_control_return: Option<std::time::Instant> = None; |
| 325 | | - const CONTROL_RETURN_COOLDOWN_MS: u64 = 500; // 500ms cooldown after control returns |
| 325 | + const CONTROL_RETURN_COOLDOWN_MS: u64 = 1000; // 1000ms cooldown after control returns (prevents bounce-back) |
| 326 | 326 | |
| 327 | 327 | // Connection storage: direction -> peer connection |
| 328 | 328 | let peers: Arc<RwLock<HashMap<Direction, network::FramedConnection>>> = |
@@ -1023,6 +1023,9 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> { |
| 1023 | 1023 | ); |
| 1024 | 1024 | if let Err(e) = transfer_manager.return_control().await { |
| 1025 | 1025 | tracing::warn!("Failed to return control: {}", e); |
| 1026 | + } else { |
| 1027 | + // Set cooldown to prevent immediate re-transfer |
| 1028 | + last_control_return = Some(std::time::Instant::now()); |
| 1026 | 1029 | } |
| 1027 | 1030 | continue; |
| 1028 | 1031 | } |
@@ -1139,6 +1142,9 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> { |
| 1139 | 1142 | ); |
| 1140 | 1143 | if let Err(e) = transfer_manager.return_control().await { |
| 1141 | 1144 | tracing::warn!("Failed to return control: {}", e); |
| 1145 | + } else { |
| 1146 | + // Set cooldown to prevent immediate re-transfer |
| 1147 | + last_control_return = Some(std::time::Instant::now()); |
| 1142 | 1148 | } |
| 1143 | 1149 | edge_dwell_start = None; |
| 1144 | 1150 | continue; |
@@ -1753,6 +1759,8 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> { |
| 1753 | 1759 | tracing::warn!("Failed to return control: {}", e); |
| 1754 | 1760 | IpcResponse::Error { message: format!("Return failed: {}", e) } |
| 1755 | 1761 | } else { |
| 1762 | + // Set cooldown to prevent immediate re-transfer (bounce-back) |
| 1763 | + last_control_return = Some(std::time::Instant::now()); |
| 1756 | 1764 | IpcResponse::Transferred { to_machine: neighbor_name.unwrap() } |
| 1757 | 1765 | } |
| 1758 | 1766 | } else { |