@@ -41,7 +41,7 @@ use crate::{
41
41
service:: { self , naming_scheme:: event_concept_name} ,
42
42
} ;
43
43
use iceoryx2_bb_lock_free:: mpmc:: container:: { ContainerHandle , ContainerState } ;
44
- use iceoryx2_bb_log:: { fail, warn} ;
44
+ use iceoryx2_bb_log:: { debug , fail, warn} ;
45
45
use iceoryx2_cal:: { dynamic_storage:: DynamicStorage , event:: NotifierBuilder } ;
46
46
use iceoryx2_cal:: { event:: Event , named_concept:: NamedConceptBuilder } ;
47
47
use std:: { cell:: UnsafeCell , rc:: Rc , sync:: atomic:: Ordering } ;
@@ -102,19 +102,36 @@ impl<Service: service::Service> ListenerConnections<Service> {
102
102
new_self
103
103
}
104
104
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" ;
106
107
let event_name = event_concept_name ( & listener_id) ;
107
108
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
+ }
115
134
}
116
-
117
- Ok ( ( ) )
118
135
}
119
136
120
137
fn get ( & self , index : usize ) -> & Option < Connection < Service > > {
@@ -180,9 +197,7 @@ impl<Service: service::Service> Notifier<Service> {
180
197
port_id,
181
198
} ;
182
199
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 ( ) ;
186
201
187
202
std:: sync:: atomic:: compiler_fence ( Ordering :: SeqCst ) ;
188
203
@@ -206,23 +221,19 @@ impl<Service: service::Service> Notifier<Service> {
206
221
Ok ( new_self)
207
222
}
208
223
209
- fn update_connections ( & self ) -> Result < ( ) , NotifierNotifyError > {
224
+ fn update_connections ( & self ) {
210
225
if unsafe {
211
226
self . dynamic_storage
212
227
. get ( )
213
228
. event ( )
214
229
. listeners
215
230
. update_state ( & mut * self . listener_list_state . get ( ) )
216
231
} {
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 ( ) ;
220
233
}
221
-
222
- Ok ( ( ) )
223
234
}
224
235
225
- fn populate_listener_channels ( & self ) -> Result < ( ) , ( ) > {
236
+ fn populate_listener_channels ( & self ) {
226
237
let mut visited_indices = vec ! [ ] ;
227
238
visited_indices. resize ( self . listener_connections . len ( ) , None ) ;
228
239
@@ -247,21 +258,12 @@ impl<Service: service::Service> Notifier<Service> {
247
258
} ;
248
259
249
260
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) ;
258
262
}
259
263
}
260
264
None => self . listener_connections . remove ( i) ,
261
265
}
262
266
}
263
-
264
- Ok ( ( ) )
265
267
}
266
268
267
269
/// Returns the [`UniqueNotifierId`] of the [`Notifier`]
@@ -288,9 +290,7 @@ impl<Service: service::Service> Notifier<Service> {
288
290
value : EventId ,
289
291
) -> Result < usize , NotifierNotifyError > {
290
292
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 ( ) ;
294
294
295
295
use iceoryx2_cal:: event:: Notifier ;
296
296
let mut number_of_triggered_listeners = 0 ;
@@ -304,6 +304,9 @@ impl<Service: service::Service> Notifier<Service> {
304
304
for i in 0 ..self . listener_connections . len ( ) {
305
305
match self . listener_connections . get ( i) {
306
306
Some ( ref connection) => match connection. notifier . notify ( value) {
307
+ Err ( iceoryx2_cal:: event:: NotifierNotifyError :: Disconnected ) => {
308
+ self . listener_connections . remove ( i) ;
309
+ }
307
310
Err ( e) => {
308
311
warn ! ( from self , "Unable to send notification via connection {:?} due to {:?}." ,
309
312
connection, e)
0 commit comments