Skip to content

Commit

Permalink
Do not trigger transport error in case of SHM buffer invalidation (#1245
Browse files Browse the repository at this point in the history
)

* Do not trigger transport error in case of SHM buffer invalidation

* Fix spelling

* Drop the whole ZBuf in case of SHM error!
  • Loading branch information
yellowhatter authored Jul 18, 2024
1 parent 8529eb6 commit c726e13
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion io/zenoh-transport/src/multicast/rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
//
use std::sync::MutexGuard;

#[cfg(feature = "shared-memory")]
use tracing::error;
use zenoh_core::{zlock, zread};
use zenoh_protocol::{
core::{Locator, Priority, Reliability},
Expand Down Expand Up @@ -44,7 +46,10 @@ impl TransportMulticastInner {
#[cfg(feature = "shared-memory")]
{
if self.manager.config.multicast.is_shm {
crate::shm::map_zmsg_to_shmbuf(&mut msg, &self.manager.shmr)?;
if let Err(e) = crate::shm::map_zmsg_to_shmbuf(&mut msg, &self.manager.shmr) {
error!("Error receiving SHM buffer: {e}");
return Ok(());
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions io/zenoh-transport/src/shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ pub fn map_zslice_to_shmbuf(zslice: &mut ZSlice, shmr: &ShmReader) -> ZResult<()
let smb = shmr.read_shmbuf(&shmbinfo)?;

// Replace the content of the slice
let zs: ZSlice = smb.into();
*zslice = zs;
*zslice = smb.into();

Ok(())
}
7 changes: 6 additions & 1 deletion io/zenoh-transport/src/unicast/lowlatency/rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
#[cfg(feature = "shared-memory")]
use tracing::error;
use zenoh_buffers::{
reader::{HasReader, Reader},
ZSlice,
Expand All @@ -37,7 +39,10 @@ impl TransportUnicastLowlatency {
#[cfg(feature = "shared-memory")]
{
if self.config.shm.is_some() {
crate::shm::map_zmsg_to_shmbuf(&mut msg, &self.manager.shmr)?;
if let Err(e) = crate::shm::map_zmsg_to_shmbuf(&mut msg, &self.manager.shmr) {
error!("Error receiving SHM buffer: {e}");
return Ok(());
}
}
}
callback.handle_message(msg)
Expand Down
7 changes: 6 additions & 1 deletion io/zenoh-transport/src/unicast/universal/rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
//
use std::sync::MutexGuard;

#[cfg(feature = "shared-memory")]
use tracing::error;
use zenoh_core::{zlock, zread};
use zenoh_link::Link;
use zenoh_protocol::{
Expand Down Expand Up @@ -45,7 +47,10 @@ impl TransportUnicastUniversal {
#[cfg(feature = "shared-memory")]
{
if self.config.shm.is_some() {
crate::shm::map_zmsg_to_shmbuf(&mut msg, &self.manager.shmr)?;
if let Err(e) = crate::shm::map_zmsg_to_shmbuf(&mut msg, &self.manager.shmr) {
error!("Error receiving SHM buffer: {e}");
return Ok(());
}
}
}
callback.handle_message(msg)
Expand Down

0 comments on commit c726e13

Please sign in to comment.