Browse Source

Delay dropping of zenoh communication layer to ensure that stop message is sent

Zenoh seems to drop the messages in its send queue when the session is closed. The stop messages are critical, so we wait a bit to ensure that they're actually sent.
tags/v0.0.0-test.4
Philipp Oppermann 3 years ago
parent
commit
5650d5dfce
Failed to extract signature
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      apis/rust/node/src/communication/zenoh.rs

+ 12
- 1
apis/rust/node/src/communication/zenoh.rs View File

@@ -1,6 +1,6 @@
use super::{CommunicationLayer, Publisher, Subscriber};
use crate::BoxError;
use std::sync::Arc;
use std::{sync::Arc, time::Duration};
use zenoh::{
prelude::{EntityFactory, Priority, Receiver as _, SplitBuffer, ZFuture},
publication::CongestionControl,
@@ -53,6 +53,17 @@ impl CommunicationLayer for ZenohCommunicationLayer {
}
}

impl Drop for ZenohCommunicationLayer {
fn drop(&mut self) {
// wait a bit before closing to ensure that remaining published
// messages are sent out
//
// TODO: create a minimal example to reproduce the dropped messages
// and report this issue in the zenoh repo
std::thread::sleep(Duration::from_secs_f32(1.0));
}
}

#[derive(Clone)]
pub struct ZenohPublisher {
publisher: zenoh::publication::Publisher<'static>,


Loading…
Cancel
Save