Skip to content

Commit d5418be

Browse files
author
Hugo Laloge
committed
Add endpoint_poll_interval_ms to configure the network change detection poll interval
1 parent cfd1111 commit d5418be

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

DEFAULT_CONFIG.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
/// increase factor for the next timeout until next try
114114
period_increase_factor: 2,
115115
},
116+
/// Interval in millisecond to check if the listening endpoints changed (i.e. when listening on 0.0.0.0 or [::]).
117+
/// Also update the multicast scouting listening interfaces. Use -1 to disable.
118+
endpoint_poll_interval_ms: 10000,
116119
},
117120
/// Configure the session open behavior.
118121
open: {

commons/zenoh-config/src/defaults.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pub mod listen {
5555

5656
pub const timeout_ms: ModeDependentValue<i64> = ModeDependentValue::Unique(0);
5757
pub const exit_on_failure: ModeDependentValue<bool> = ModeDependentValue::Unique(true);
58+
59+
pub const endpoint_poll_interval_ms: Option<i64> = Some(10_000);
5860
}
5961

6062
#[allow(non_upper_case_globals)]
@@ -180,6 +182,7 @@ impl Default for ListenConfig {
180182
peer: Some(vec![]),
181183
client: None,
182184
}),
185+
endpoint_poll_interval_ms: Some(10_000),
183186
exit_on_failure: None,
184187
retry: None,
185188
}

commons/zenoh-config/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ validated_struct::validator! {
384384
/// if connection timeout exceed, exit from application
385385
pub exit_on_failure: Option<ModeDependentValue<bool>>,
386386
pub retry: Option<connection_retry::ConnectionRetryModeDependentConf>,
387+
/// Interval in millisecond to check if the listening endpoints changed (e.g. when listening on 0.0.0.0).
388+
/// Also update the multicast scouting listening interfaces. Use -1 to disable.
389+
pub endpoint_poll_interval_ms: Option<i64>,
387390
},
388391
/// Configure the session open behavior.
389392
pub open: #[derive(Default)]

zenoh/src/net/runtime/mod.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,21 @@ impl Runtime {
380380
}
381381

382382
async fn monitor_available_addrs(&self) {
383-
let token = self.get_cancellation_token();
384-
let update_interval = Duration::from_secs(10);
385-
loop {
386-
tokio::select! {
387-
_ = tokio::time::sleep(update_interval) => self.update_available_addrs().await,
388-
_ = token.cancelled() => return,
383+
let update_interval_ms = self
384+
.config()
385+
.lock()
386+
.0
387+
.listen
388+
.endpoint_poll_interval_ms()
389+
.unwrap_or(10_000);
390+
if update_interval_ms > 0 {
391+
let update_interval = Duration::from_millis(update_interval_ms as u64);
392+
let token = self.get_cancellation_token();
393+
loop {
394+
tokio::select! {
395+
_ = tokio::time::sleep(update_interval) => self.update_available_addrs().await,
396+
_ = token.cancelled() => return,
397+
}
389398
}
390399
}
391400
}

0 commit comments

Comments
 (0)