From 411436d3bb8e294bc547f27b87f0e80c7db56d61 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Thu, 5 Dec 2024 13:43:09 +0100 Subject: [PATCH] Replace drop token mecanism on closed channel by leaving drop token active on the receiver side and closing sender side shared memory with a lower timeout --- apis/rust/node/src/event_stream/thread.rs | 3 +-- apis/rust/node/src/node/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apis/rust/node/src/event_stream/thread.rs b/apis/rust/node/src/event_stream/thread.rs index b5386aa1..5e982f74 100644 --- a/apis/rust/node/src/event_stream/thread.rs +++ b/apis/rust/node/src/event_stream/thread.rs @@ -237,13 +237,12 @@ fn report_remaining_drop_tokens( drop_tokens.push(token); } Err(flume::RecvTimeoutError::Timeout) => { - let duration = Duration::from_secs(2); + let duration = Duration::from_secs(1); if since.elapsed() > duration { tracing::warn!( "timeout: node finished, but token {token:?} was still not \ dropped after {duration:?} -> ignoring it" ); - drop_tokens.push(token); } else { still_pending.push((token, rx, since, 0)); } diff --git a/apis/rust/node/src/node/mod.rs b/apis/rust/node/src/node/mod.rs index ee8d75a1..009e1b81 100644 --- a/apis/rust/node/src/node/mod.rs +++ b/apis/rust/node/src/node/mod.rs @@ -409,14 +409,14 @@ impl Drop for DoraNode { ); } - match self.drop_stream.recv_timeout(Duration::from_secs(10)) { + match self.drop_stream.recv_timeout(Duration::from_secs(2)) { Ok(token) => { self.sent_out_shared_memory.remove(&token); } Err(flume::RecvTimeoutError::Disconnected) => { tracing::warn!( "finished_drop_tokens channel closed while still waiting for drop tokens; \ - closing {} shared memory regions that might still be used", + closing {} shared memory regions that might not yet been mapped.", self.sent_out_shared_memory.len() ); break; @@ -424,7 +424,7 @@ impl Drop for DoraNode { Err(flume::RecvTimeoutError::Timeout) => { tracing::warn!( "timeout while waiting for drop tokens; \ - closing {} shared memory regions that might still be used", + closing {} shared memory regions that might not yet been mapped.", self.sent_out_shared_memory.len() ); break;