Skip to content

Commit 009f666

Browse files
authored
fix: make rx task close the link properly in low-latency transport (#1030)
1 parent 3118d31 commit 009f666

File tree

1 file changed

+21
-17
lines changed
  • io/zenoh-transport/src/unicast/lowlatency

1 file changed

+21
-17
lines changed

io/zenoh-transport/src/unicast/lowlatency/link.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl TransportUnicastLowlatency {
144144
let token = self.token.child_token();
145145

146146
let c_transport = self.clone();
147-
let task = async move {
147+
let rx_task = async move {
148148
let guard = zasyncread!(c_transport.link);
149149
let link_rx = guard.as_ref().unwrap().rx();
150150
drop(guard);
@@ -165,7 +165,7 @@ impl TransportUnicastLowlatency {
165165
zenoh_sync::RecyclingObjectPool::new(n, move || vec![0_u8; mtu].into_boxed_slice())
166166
};
167167

168-
let res = loop {
168+
loop {
169169
// Retrieve one buffer
170170
let mut buffer = pool.try_take().unwrap_or_else(|| pool.alloc());
171171

@@ -188,25 +188,29 @@ impl TransportUnicastLowlatency {
188188
break ZResult::Ok(());
189189
}
190190
}
191-
};
191+
}
192+
};
192193

193-
tracing::debug!(
194-
"[{}] Rx task finished with result {:?}",
195-
c_transport.manager.config.zid,
196-
res
197-
);
198-
if res.is_err() {
194+
let c_transport = self.clone();
195+
self.tracker.spawn_on(
196+
async move {
197+
let res = rx_task.await;
199198
tracing::debug!(
200-
"[{}] <on rx exit> finalizing transport with peer: {}",
199+
"[{}] Rx task finished with result {:?}",
201200
c_transport.manager.config.zid,
202-
c_transport.config.zid
201+
res
203202
);
204-
let _ = c_transport.finalize(0).await;
205-
}
206-
ZResult::Ok(())
207-
};
208-
209-
self.tracker.spawn_on(task, &ZRuntime::TX);
203+
if res.is_err() {
204+
tracing::debug!(
205+
"[{}] <on rx exit> finalizing transport with peer: {}",
206+
c_transport.manager.config.zid,
207+
c_transport.config.zid
208+
);
209+
let _ = c_transport.finalize(0).await;
210+
}
211+
},
212+
&ZRuntime::RX,
213+
);
210214
}
211215
}
212216

0 commit comments

Comments
 (0)