Skip to content

Commit 16a1a02

Browse files
committed
[eclipse-iceoryx#139] Failing to send notification due to listener problems does not cause failure on notifier side
1 parent b52c392 commit 16a1a02

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

iceoryx2/src/port/notifier.rs

+37-34
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::{
4141
service::{self, naming_scheme::event_concept_name},
4242
};
4343
use iceoryx2_bb_lock_free::mpmc::container::{ContainerHandle, ContainerState};
44-
use iceoryx2_bb_log::{fail, warn};
44+
use iceoryx2_bb_log::{debug, fail, warn};
4545
use iceoryx2_cal::{dynamic_storage::DynamicStorage, event::NotifierBuilder};
4646
use iceoryx2_cal::{event::Event, named_concept::NamedConceptBuilder};
4747
use std::{cell::UnsafeCell, rc::Rc, sync::atomic::Ordering};
@@ -102,19 +102,36 @@ impl<Service: service::Service> ListenerConnections<Service> {
102102
new_self
103103
}
104104

105-
fn create(&self, index: usize, listener_id: UniqueListenerId) -> Result<(), ()> {
105+
fn create(&self, index: usize, listener_id: UniqueListenerId) {
106+
let msg = "Unable to establish connection to listener";
106107
let event_name = event_concept_name(&listener_id);
107108
if self.get(index).is_none() {
108-
let notifier = fail!(from self, when <Service::Event as iceoryx2_cal::event::Event>::NotifierBuilder::new(&event_name).open(),
109-
with (),
110-
"Unable to establish a connection to Listener port {:?}.", listener_id);
111-
*self.get_mut(index) = Some(Connection {
112-
notifier,
113-
listener_id,
114-
});
109+
match <Service::Event as iceoryx2_cal::event::Event>::NotifierBuilder::new(&event_name)
110+
.open()
111+
{
112+
Ok(notifier) => {
113+
*self.get_mut(index) = Some(Connection {
114+
notifier,
115+
listener_id,
116+
});
117+
}
118+
Err(
119+
iceoryx2_cal::event::NotifierCreateError::DoesNotExist
120+
| iceoryx2_cal::event::NotifierCreateError::InitializationNotYetFinalized,
121+
) => (),
122+
Err(iceoryx2_cal::event::NotifierCreateError::VersionMismatch) => {
123+
warn!(from self,
124+
"{} since a version mismatch was detected! All entities must use the same iceoryx2 version!",
125+
msg);
126+
}
127+
Err(iceoryx2_cal::event::NotifierCreateError::InsufficientPermissions) => {
128+
warn!(from self, "{} since the permissions do not match. The service or the participants are maybe misconfigured.", msg);
129+
}
130+
Err(iceoryx2_cal::event::NotifierCreateError::InternalFailure) => {
131+
debug!(from self, "{} due to an internal failure.", msg);
132+
}
133+
}
115134
}
116-
117-
Ok(())
118135
}
119136

120137
fn get(&self, index: usize) -> &Option<Connection<Service>> {
@@ -180,9 +197,7 @@ impl<Service: service::Service> Notifier<Service> {
180197
port_id,
181198
};
182199

183-
if let Err(e) = new_self.populate_listener_channels() {
184-
warn!(from new_self, "The new Notifier port is unable to connect to every Listener port, caused by {:?}.", e);
185-
}
200+
new_self.populate_listener_channels();
186201

187202
std::sync::atomic::compiler_fence(Ordering::SeqCst);
188203

@@ -206,23 +221,19 @@ impl<Service: service::Service> Notifier<Service> {
206221
Ok(new_self)
207222
}
208223

209-
fn update_connections(&self) -> Result<(), NotifierNotifyError> {
224+
fn update_connections(&self) {
210225
if unsafe {
211226
self.dynamic_storage
212227
.get()
213228
.event()
214229
.listeners
215230
.update_state(&mut *self.listener_list_state.get())
216231
} {
217-
fail!(from self, when self.populate_listener_channels(),
218-
with NotifierNotifyError::OnlyPartialUpdate,
219-
"Connections were updated only partially since at least one connection to a Listener port failed.");
232+
self.populate_listener_channels();
220233
}
221-
222-
Ok(())
223234
}
224235

225-
fn populate_listener_channels(&self) -> Result<(), ()> {
236+
fn populate_listener_channels(&self) {
226237
let mut visited_indices = vec![];
227238
visited_indices.resize(self.listener_connections.len(), None);
228239

@@ -247,21 +258,12 @@ impl<Service: service::Service> Notifier<Service> {
247258
};
248259

249260
if create_connection {
250-
match self.listener_connections.create(i, *listener_id) {
251-
Ok(()) => (),
252-
Err(()) => {
253-
fail!(from self, with (),
254-
"Unable to establish connection to Listener port {:?}.",
255-
*listener_id);
256-
}
257-
};
261+
self.listener_connections.create(i, *listener_id);
258262
}
259263
}
260264
None => self.listener_connections.remove(i),
261265
}
262266
}
263-
264-
Ok(())
265267
}
266268

267269
/// Returns the [`UniqueNotifierId`] of the [`Notifier`]
@@ -288,9 +290,7 @@ impl<Service: service::Service> Notifier<Service> {
288290
value: EventId,
289291
) -> Result<usize, NotifierNotifyError> {
290292
let msg = "Unable to notify event";
291-
fail!(from self, when self.update_connections(),
292-
"{} with id {:?} since the underlying connections could not be updated.",
293-
msg, value);
293+
self.update_connections();
294294

295295
use iceoryx2_cal::event::Notifier;
296296
let mut number_of_triggered_listeners = 0;
@@ -304,6 +304,9 @@ impl<Service: service::Service> Notifier<Service> {
304304
for i in 0..self.listener_connections.len() {
305305
match self.listener_connections.get(i) {
306306
Some(ref connection) => match connection.notifier.notify(value) {
307+
Err(iceoryx2_cal::event::NotifierNotifyError::Disconnected) => {
308+
self.listener_connections.remove(i);
309+
}
307310
Err(e) => {
308311
warn!(from self, "Unable to send notification via connection {:?} due to {:?}.",
309312
connection, e)

iceoryx2/tests/service_event_tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ mod service_event {
431431
}
432432

433433
#[test]
434-
#[ignore]
435434
fn concurrent_reconnecting_notifier_can_trigger_waiting_listener<Sut: Service>() {
436435
let _watch_dog = Watchdog::new();
437436

0 commit comments

Comments
 (0)