diff --git a/Cargo.lock b/Cargo.lock index d641d4f2..85befa97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -409,7 +409,7 @@ checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -491,24 +491,24 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.60.1" +version = "0.68.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" +checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" dependencies = [ - "bitflags", + "bitflags 2.4.0", "cexpr", "clang-sys", - "clap 3.2.25", - "env_logger 0.9.3", "lazy_static", "lazycell", "log", "peeking_take_while", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", + "syn 2.0.32", "which", ] @@ -533,6 +533,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "blake3" version = "0.3.8" @@ -704,7 +710,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex 0.2.4", "indexmap 1.9.3", "strsim", @@ -744,7 +750,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -923,7 +929,7 @@ dependencies = [ [[package]] name = "cyclors" version = "0.2.0" -source = "git+https://github.com/kydos/cyclors?branch=master#45d50e7c71584c1cd7468f95f400cdc43a944f71" +source = "git+https://github.com/kydos/cyclors?branch=master#8f831b3b0a7fc8a63098a82a5c079dc3562405a7" dependencies = [ "bincode", "bindgen", @@ -1032,19 +1038,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.10.0" @@ -1250,7 +1243,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -1927,7 +1920,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "libc", "memoffset", @@ -2195,7 +2188,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -2236,7 +2229,7 @@ checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -2377,7 +2370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "concurrent-queue", "libc", @@ -2403,6 +2396,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn 2.0.32", +] + [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -2552,7 +2555,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2561,7 +2564,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2725,7 +2728,7 @@ version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -2837,7 +2840,7 @@ version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -2892,7 +2895,7 @@ checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -3304,9 +3307,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -3345,7 +3348,7 @@ checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -3497,7 +3500,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -3553,7 +3556,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", ] [[package]] @@ -3596,7 +3599,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "static_assertions", ] @@ -3848,7 +3851,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", "wasm-bindgen-shared", ] @@ -3882,7 +3885,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4044,7 +4047,7 @@ dependencies = [ "async-std", "async-trait", "base64 0.21.2", - "env_logger 0.10.0", + "env_logger", "event-listener", "flume", "form_urlencoded", @@ -4089,7 +4092,7 @@ dependencies = [ "async-liveliness-monitor", "async-std", "clap 3.2.25", - "env_logger 0.10.0", + "env_logger", "lazy_static", "log", "serde_json", @@ -4172,7 +4175,7 @@ source = "git+https://github.com/eclipse-zenoh/zenoh?branch=master#108dc59c18406 dependencies = [ "async-std", "bincode", - "env_logger 0.10.0", + "env_logger", "flume", "futures", "log", @@ -4377,7 +4380,7 @@ dependencies = [ "cdr", "cyclors", "derivative", - "env_logger 0.10.0", + "env_logger", "flume", "futures", "git-version", @@ -4405,7 +4408,7 @@ dependencies = [ "async-std", "base64 0.21.2", "clap 3.2.25", - "env_logger 0.10.0", + "env_logger", "flume", "futures", "git-version", diff --git a/zenoh-plugin-dds/src/dds_mgt.rs b/zenoh-plugin-dds/src/dds_mgt.rs index 50819d4e..21e5f5d0 100644 --- a/zenoh-plugin-dds/src/dds_mgt.rs +++ b/zenoh-plugin-dds/src/dds_mgt.rs @@ -32,7 +32,7 @@ use zenoh::publication::CongestionControl; use zenoh::Session; use zenoh_core::SyncResolve; -const MAX_SAMPLES: u32 = 32; +const MAX_SAMPLES: usize = 32; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub(crate) enum RouteStatus { @@ -191,6 +191,11 @@ impl DDSRawSample { } fn data_as_slice(&self) -> &[u8] { + #[cfg(not(target_os = "windows"))] + unsafe { + slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len) + } + #[cfg(target_os = "windows")] unsafe { slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len as usize) } @@ -204,7 +209,15 @@ impl DDSRawSample { return iox_chunk.as_slice(); } } - &slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len as usize)[4..] + #[cfg(not(target_os = "windows"))] + { + &slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len)[4..] + } + #[cfg(target_os = "windows")] + { + &slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len as usize) + [4..] + } } } @@ -278,17 +291,17 @@ unsafe extern "C" fn on_data(dr: dds_entity_t, arg: *mut std::os::raw::c_void) { let _ = dds_get_instance_handle(dp, &mut dpih); #[allow(clippy::uninit_assumed_init)] - let mut si = MaybeUninit::<[dds_sample_info_t; MAX_SAMPLES as usize]>::uninit(); - let mut samples: [*mut ::std::os::raw::c_void; MAX_SAMPLES as usize] = - [std::ptr::null_mut(); MAX_SAMPLES as usize]; + let mut si = MaybeUninit::<[dds_sample_info_t; MAX_SAMPLES]>::uninit(); + let mut samples: [*mut ::std::os::raw::c_void; MAX_SAMPLES] = + [std::ptr::null_mut(); MAX_SAMPLES]; samples[0] = std::ptr::null_mut(); let n = dds_take( dr, samples.as_mut_ptr() as *mut *mut raw::c_void, si.as_mut_ptr() as *mut dds_sample_info_t, - MAX_SAMPLES.into(), MAX_SAMPLES, + MAX_SAMPLES as u32, ); let si = si.assume_init(); diff --git a/zenoh-plugin-dds/src/ros_discovery.rs b/zenoh-plugin-dds/src/ros_discovery.rs index 3a30ee6a..f41b52cc 100644 --- a/zenoh-plugin-dds/src/ros_discovery.rs +++ b/zenoh-plugin-dds/src/ros_discovery.rs @@ -184,22 +184,25 @@ impl RosDiscoveryInfoMgr { // that is not necessarily safe or guaranteed to be leak free. // TODO replace when stable https://github.com/rust-lang/rust/issues/65816 let (ptr, len, capacity) = crate::vec_into_raw_parts(buf); - let size: ddsrt_iov_len_t = len.try_into().map_err(|e| { - format!("Error creating payload for ParticipantEntitiesInfo, excessive payload size: {e}") - })?; - - let data_out = ddsrt_iovec_t { - iov_base: ptr as *mut std::ffi::c_void, - iov_len: size, - }; - - let fwdp = ddsi_serdata_from_ser_iov( - sertype, - ddsi_serdata_kind_SDK_DATA, - 1, - &data_out, - size as usize, - ); + + let data_out: ddsrt_iovec_t; + #[cfg(not(target_os = "windows"))] + { + data_out = ddsrt_iovec_t { + iov_base: ptr as *mut std::ffi::c_void, + iov_len: len, + }; + } + #[cfg(target_os = "windows")] + { + data_out = ddsrt_iovec_t { + iov_base: ptr as *mut std::ffi::c_void, + iov_len: len as u32, + }; + } + + let fwdp = + ddsi_serdata_from_ser_iov(sertype, ddsi_serdata_kind_SDK_DATA, 1, &data_out, len); dds_writecdr(self.writer, fwdp); drop(Vec::from_raw_parts(ptr, len, capacity)); Ok(()) diff --git a/zenoh-plugin-dds/src/route_zenoh_dds.rs b/zenoh-plugin-dds/src/route_zenoh_dds.rs index 8fffcbb8..2f5641f5 100644 --- a/zenoh-plugin-dds/src/route_zenoh_dds.rs +++ b/zenoh-plugin-dds/src/route_zenoh_dds.rs @@ -14,11 +14,10 @@ use cyclors::{ dds_entity_t, dds_get_entity_sertype, dds_strretcode, dds_writecdr, ddsi_serdata_from_ser_iov, - ddsi_serdata_kind_SDK_DATA, ddsi_sertype, ddsrt_iov_len_t, ddsrt_iovec_t, + ddsi_serdata_kind_SDK_DATA, ddsi_sertype, ddsrt_iovec_t, }; use serde::{Serialize, Serializer}; use std::collections::HashSet; -use std::convert::TryInto; use std::sync::atomic::Ordering; use std::sync::Arc; use std::{ffi::CStr, fmt, sync::atomic::AtomicI32, time::Duration}; @@ -380,23 +379,22 @@ fn do_route_data(s: Sample, topic_name: &str, data_writer: dds_entity_t) { // that is not necessarily safe or guaranteed to be leak free. // TODO replace when stable https://github.com/rust-lang/rust/issues/65816 let (ptr, len, capacity) = vec_into_raw_parts(bs); - let size: ddsrt_iov_len_t = match len.try_into() { - Ok(s) => s, - Err(_) => { - log::warn!( - "Route Zenoh->DDS ({} -> {}): can't route data; excessive payload size ({})", - s.key_expr, - topic_name, - len - ); - return; - } - }; - let data_out = ddsrt_iovec_t { - iov_base: ptr as *mut std::ffi::c_void, - iov_len: size, - }; + let data_out: ddsrt_iovec_t; + #[cfg(not(target_os = "windows"))] + { + data_out = ddsrt_iovec_t { + iov_base: ptr as *mut std::ffi::c_void, + iov_len: len, + }; + } + #[cfg(target_os = "windows")] + { + data_out = ddsrt_iovec_t { + iov_base: ptr as *mut std::ffi::c_void, + iov_len: len as u32, + }; + } let mut sertype_ptr: *const ddsi_sertype = std::ptr::null_mut(); let ret = dds_get_entity_sertype(data_writer, &mut sertype_ptr); @@ -412,13 +410,8 @@ fn do_route_data(s: Sample, topic_name: &str, data_writer: dds_entity_t) { return; } - let fwdp = ddsi_serdata_from_ser_iov( - sertype_ptr, - ddsi_serdata_kind_SDK_DATA, - 1, - &data_out, - size as usize, - ); + let fwdp = + ddsi_serdata_from_ser_iov(sertype_ptr, ddsi_serdata_kind_SDK_DATA, 1, &data_out, len); dds_writecdr(data_writer, fwdp); drop(Vec::from_raw_parts(ptr, len, capacity));