From 65f3f09e7634b826b685db73eb3fef1d82f73310 Mon Sep 17 00:00:00 2001 From: OlivierHecart Date: Fri, 27 Sep 2024 13:19:11 +0200 Subject: [PATCH] Avoid waiting for dropping deadline if wait time is null --- io/zenoh-transport/src/common/pipeline.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/io/zenoh-transport/src/common/pipeline.rs b/io/zenoh-transport/src/common/pipeline.rs index 8a712d56db..16ed92bca3 100644 --- a/io/zenoh-transport/src/common/pipeline.rs +++ b/io/zenoh-transport/src/common/pipeline.rs @@ -141,7 +141,7 @@ impl StageIn { &mut self, msg: &mut NetworkMessage, priority: Priority, - deadline_before_drop: Option, + deadline_before_drop: Option>, ) -> bool { // Lock the current serialization batch. let mut c_guard = self.mutex.current(); @@ -163,7 +163,7 @@ impl StageIn { Some(deadline) if !$fragment => { // We are in the congestion scenario and message is droppable // Wait for an available batch until deadline - if !self.s_ref.wait_deadline(deadline) { + if !deadline.map_or(false, |deadline| self.s_ref.wait_deadline(deadline)) { // Still no available batch. // Restore the sequence number and drop the message $restore_sn; @@ -628,7 +628,11 @@ impl TransmissionPipelineProducer { }; // If message is droppable, compute a deadline after which the sample could be dropped let deadline_before_drop = if msg.is_droppable() { - Some(Instant::now() + self.wait_before_drop) + if self.wait_before_drop.is_zero() { + Some(None) + } else { + Some(Some(Instant::now() + self.wait_before_drop)) + } } else { None };