diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index 9e160970d..d66d33cd1 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -710,6 +710,7 @@ impl Drop for SharedNode { } /// The [`Node`] is the entry point to the whole iceoryx2 infrastructure and owns all entities. +/// /// As soon as a process crashes other processes can detect dead [`Node`]s via [`Node::list()`] /// and clean up the stale resources - the entities that /// were created via the [`Node`]. diff --git a/iceoryx2/src/port/notifier.rs b/iceoryx2/src/port/notifier.rs index 67274d680..ae64a7676 100644 --- a/iceoryx2/src/port/notifier.rs +++ b/iceoryx2/src/port/notifier.rs @@ -340,21 +340,18 @@ impl Notifier { } for i in 0..self.listener_connections.len() { - match self.listener_connections.get(i) { - Some(ref connection) => match connection.notifier.notify(value) { - Err(iceoryx2_cal::event::NotifierNotifyError::Disconnected) => { - self.listener_connections.remove(i); - } - Err(e) => { - warn!(from self, "Unable to send notification via connection {:?} due to {:?}.", - connection, e) - } - Ok(_) => { - number_of_triggered_listeners += 1; - } - }, - None => (), - } + if let Some(ref connection) = self.listener_connections.get(i) { match connection.notifier.notify(value) { + Err(iceoryx2_cal::event::NotifierNotifyError::Disconnected) => { + self.listener_connections.remove(i); + } + Err(e) => { + warn!(from self, "Unable to send notification via connection {:?} due to {:?}.", + connection, e) + } + Ok(_) => { + number_of_triggered_listeners += 1; + } + } } } Ok(number_of_triggered_listeners) diff --git a/iceoryx2/src/port/publisher.rs b/iceoryx2/src/port/publisher.rs index f9c8ca4df..46a5f4c94 100644 --- a/iceoryx2/src/port/publisher.rs +++ b/iceoryx2/src/port/publisher.rs @@ -292,20 +292,17 @@ impl DataSegment { fn retrieve_returned_samples(&self) { for i in 0..self.subscriber_connections.len() { - match self.subscriber_connections.get(i) { - Some(ref connection) => loop { - match connection.sender.reclaim() { - Ok(Some(ptr_dist)) => { - self.release_sample(ptr_dist); - } - Ok(None) => break, - Err(e) => { - warn!(from self, "Unable to reclaim samples from connection {:?} due to {:?}. This may lead to a situation where no more samples will be delivered to this connection.", connection, e) - } + if let Some(ref connection) = self.subscriber_connections.get(i) { loop { + match connection.sender.reclaim() { + Ok(Some(ptr_dist)) => { + self.release_sample(ptr_dist); } - }, - None => (), - } + Ok(None) => break, + Err(e) => { + warn!(from self, "Unable to reclaim samples from connection {:?} due to {:?}. This may lead to a situation where no more samples will be delivered to this connection.", connection, e) + } + } + } } } } @@ -356,53 +353,50 @@ impl DataSegment { let mut number_of_recipients = 0; for i in 0..self.subscriber_connections.len() { - match self.subscriber_connections.get(i) { - Some(ref connection) => { - match deliver_call(&connection.sender, PointerOffset::new(address_to_chunk)) { - Err(ZeroCopySendError::ReceiveBufferFull) - | Err(ZeroCopySendError::UsedChunkListFull) => { - /* causes no problem - * blocking_send => can never happen - * try_send => we tried and expect that the buffer is full - * */ - } - Err(ZeroCopySendError::ConnectionCorrupted) => { - match &self.config.degration_callback { - Some(c) => match c.call( - self.static_config.clone(), - self.port_id, - connection.subscriber_id, - ) { - DegrationAction::Ignore => (), - DegrationAction::Warn => { - error!(from self, - "While delivering the sample: {:?} a corrupted connection was detected with subscriber {:?}.", - address_to_chunk, connection.subscriber_id); - } - DegrationAction::Fail => { - fail!(from self, with PublisherSendError::ConnectionCorrupted, - "While delivering the sample: {:?} a corrupted connection was detected with subscriber {:?}.", - address_to_chunk, connection.subscriber_id); - } - }, - None => { + if let Some(ref connection) = self.subscriber_connections.get(i) { + match deliver_call(&connection.sender, PointerOffset::new(address_to_chunk)) { + Err(ZeroCopySendError::ReceiveBufferFull) + | Err(ZeroCopySendError::UsedChunkListFull) => { + /* causes no problem + * blocking_send => can never happen + * try_send => we tried and expect that the buffer is full + * */ + } + Err(ZeroCopySendError::ConnectionCorrupted) => { + match &self.config.degration_callback { + Some(c) => match c.call( + self.static_config.clone(), + self.port_id, + connection.subscriber_id, + ) { + DegrationAction::Ignore => (), + DegrationAction::Warn => { error!(from self, "While delivering the sample: {:?} a corrupted connection was detected with subscriber {:?}.", address_to_chunk, connection.subscriber_id); } + DegrationAction::Fail => { + fail!(from self, with PublisherSendError::ConnectionCorrupted, + "While delivering the sample: {:?} a corrupted connection was detected with subscriber {:?}.", + address_to_chunk, connection.subscriber_id); + } + }, + None => { + error!(from self, + "While delivering the sample: {:?} a corrupted connection was detected with subscriber {:?}.", + address_to_chunk, connection.subscriber_id); } } - Ok(overflow) => { - self.borrow_sample(address_to_chunk); - number_of_recipients += 1; + } + Ok(overflow) => { + self.borrow_sample(address_to_chunk); + number_of_recipients += 1; - if let Some(old) = overflow { - self.release_sample(old) - } + if let Some(old) = overflow { + self.release_sample(old) } } } - None => (), } } Ok(number_of_recipients) diff --git a/iceoryx2/src/port/subscriber.rs b/iceoryx2/src/port/subscriber.rs index 596f25d1b..6626a5aa5 100644 --- a/iceoryx2/src/port/subscriber.rs +++ b/iceoryx2/src/port/subscriber.rs @@ -335,13 +335,10 @@ impl "Some samples are not being received since not all connections to publishers could be established."); for id in 0..self.publisher_connections.len() { - match &self.publisher_connections.get(id) { - Some(ref connection) => { - if connection.receiver.has_data() { - return Ok(true); - } + if let Some(ref connection) = &self.publisher_connections.get(id) { + if connection.receiver.has_data() { + return Ok(true); } - None => (), } } @@ -368,15 +365,12 @@ impl } for id in 0..self.publisher_connections.len() { - match &mut self.publisher_connections.get_mut(id) { - Some(ref mut connection) => { - if let Some((details, absolute_address)) = - self.receive_from_connection(connection)? - { - return Ok(Some((details, absolute_address))); - } + if let Some(ref mut connection) = &mut self.publisher_connections.get_mut(id) { + if let Some((details, absolute_address)) = + self.receive_from_connection(connection)? + { + return Ok(Some((details, absolute_address))); } - None => (), } }