Skip to content

Commit 5d2a194

Browse files
author
Hugo Laloge
committed
Hide the netlink monitoring behind cfg(target_os = "linux")
1 parent 6087d18 commit 5d2a194

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

zenoh/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ petgraph = { workspace = true }
9898
phf = { workspace = true }
9999
rand = { workspace = true, features = ["default"] }
100100
ref-cast = { workspace = true }
101-
rtnetlink = { workspace = true }
102101
serde = { workspace = true, features = ["default"] }
103102
serde_json = { workspace = true }
104103
socket2 = { workspace = true }
@@ -123,6 +122,9 @@ zenoh-runtime = { workspace = true }
123122
zenoh-task = { workspace = true }
124123
once_cell = { workspace = true }
125124

125+
[target.'cfg(target_os = "linux")'.dependencies]
126+
rtnetlink = { workspace = true }
127+
126128
[dev-dependencies]
127129
tokio = { workspace = true }
128130

zenoh/src/net/runtime/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//!
1919
//! [Click here for Zenoh's documentation](https://docs.rs/zenoh/latest/zenoh)
2020
mod adminspace;
21-
#[cfg(unix)]
21+
#[cfg(target_os = "linux")]
2222
mod netlink;
2323
pub mod orchestrator;
2424
mod scouting;
@@ -83,7 +83,7 @@ use crate::{
8383
GIT_VERSION, LONG_VERSION,
8484
};
8585

86-
#[cfg(unix)]
86+
#[cfg(target_os = "linux")]
8787
const NETLINK_TIMEOUT: Duration = Duration::from_millis(500);
8888

8989
pub(crate) struct RuntimeState {
@@ -256,7 +256,7 @@ impl RuntimeBuilder {
256256
zenoh_config::ShmInitMode::Lazy => {}
257257
};
258258

259-
#[cfg(unix)]
259+
#[cfg(target_os = "linux")]
260260
runtime.spawn({
261261
let netlink_monitor = netlink::NetlinkMonitor::new()?;
262262
let runtime2 = runtime.clone();
@@ -390,7 +390,7 @@ impl Runtime {
390390
self.state.pending_connections.lock().await.remove(zid)
391391
}
392392

393-
#[cfg(unix)]
393+
#[cfg(target_os = "linux")]
394394
async fn monitor_netlink_socket(&self, mut netlink: netlink::NetlinkMonitor) {
395395
fn add_addr_to_set(
396396
message: &AddressMessage,

0 commit comments

Comments
 (0)