From b2aa3c3d0774b31865718ebdeeabcb6c9c690da8 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Thu, 10 Jul 2025 18:00:01 +0100 Subject: [PATCH] refactor: update statime Port API method calls for timer and message handling Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) --- src/ptp.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ptp.rs b/src/ptp.rs index 0a2dfc1..85c0b85 100644 --- a/src/ptp.rs +++ b/src/ptp.rs @@ -102,7 +102,7 @@ async fn run_ptp_session( // 5. Create network handles fn create_socket( - interface: &str, + _interface: &str, port: u16, ) -> Result> { let socket = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::UDP))?; @@ -159,22 +159,20 @@ async fn run_ptp_session( return Ok(()); } - let timer_instant = running_port - .get_next_timer_instant() - .map(tokio::time::Instant::from_std) - .unwrap_or_else(|| tokio::time::Instant::now() + Duration::from_secs(1)); - actions = Vec::new(); tokio::select! { - _ = tokio::time::sleep_until(timer_instant) => { - actions.extend(running_port.handle_timer()); + _ = tokio::time::sleep(Duration::from_millis(100)) => { + // Handle periodic timer events + actions.extend(running_port.handle_sync_timer()); + actions.extend(running_port.handle_announce_timer()); + actions.extend(running_port.handle_delay_request_timer()); } Ok((len, source_address)) = event_socket.recv_from(&mut event_buf) => { - actions.extend(running_port.handle_message(&event_buf[..len], source_address)); + actions.extend(running_port.handle_event_receive(&event_buf[..len], source_address)); } Ok((len, source_address)) = general_socket.recv_from(&mut general_buf) => { - actions.extend(running_port.handle_message(&general_buf[..len], source_address)); + actions.extend(running_port.handle_general_receive(&general_buf[..len], source_address)); } }