mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
refactor: resolve multiple mutable borrow issues in PTP session handling
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
parent
626d282022
commit
6454d5f5ce
1 changed files with 4 additions and 4 deletions
|
|
@ -129,7 +129,8 @@ async fn run_ptp_session(
|
||||||
let mut general_buf = [0u8; 1500];
|
let mut general_buf = [0u8; 1500];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for action in actions {
|
// Process any pending actions first
|
||||||
|
for action in actions.drain(..) {
|
||||||
match action {
|
match action {
|
||||||
PortAction::SendEvent { data, .. } => {
|
PortAction::SendEvent { data, .. } => {
|
||||||
// Send to PTP multicast address for events
|
// Send to PTP multicast address for events
|
||||||
|
|
@ -159,11 +160,10 @@ async fn run_ptp_session(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
actions = Vec::new();
|
// Handle events and collect new actions
|
||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = tokio::time::sleep(Duration::from_millis(100)) => {
|
_ = 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_sync_timer());
|
||||||
actions.extend(running_port.handle_announce_timer(&mut NoForwardedTLVs));
|
actions.extend(running_port.handle_announce_timer(&mut NoForwardedTLVs));
|
||||||
actions.extend(running_port.handle_delay_request_timer());
|
actions.extend(running_port.handle_delay_request_timer());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue