From 6454d5f5ce7af01cc009b00181a08ac65ace06ce Mon Sep 17 00:00:00 2001 From: John Rogers Date: Thu, 10 Jul 2025 18:14:00 +0100 Subject: [PATCH] refactor: resolve multiple mutable borrow issues in PTP session handling Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) --- src/ptp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ptp.rs b/src/ptp.rs index a81f76c..5e82832 100644 --- a/src/ptp.rs +++ b/src/ptp.rs @@ -129,7 +129,8 @@ async fn run_ptp_session( let mut general_buf = [0u8; 1500]; loop { - for action in actions { + // Process any pending actions first + for action in actions.drain(..) { match action { PortAction::SendEvent { data, .. } => { // Send to PTP multicast address for events @@ -159,11 +160,10 @@ async fn run_ptp_session( return Ok(()); } - actions = Vec::new(); - + // Handle events and collect new actions tokio::select! { _ = tokio::time::sleep(Duration::from_millis(100)) => { - // Handle periodic timer events + // Handle periodic timer events one at a time to avoid multiple mutable borrows actions.extend(running_port.handle_sync_timer()); actions.extend(running_port.handle_announce_timer(&mut NoForwardedTLVs)); actions.extend(running_port.handle_delay_request_timer());