@@ -123,18 +123,31 @@ impl WaitSet {
123
123
// the waitable of each primitive to one (and only one) WaitSet when
124
124
// the primitive gets constructed. The waitables are never allowed to
125
125
// move between wait sets.
126
- let r = unsafe { rcl_wait ( & mut self . handle . rcl_wait_set , timeout_ns) } . ok ( ) ;
126
+ let r = match unsafe { rcl_wait ( & mut self . handle . rcl_wait_set , timeout_ns) } . ok ( )
127
+ {
128
+ Ok ( _) => Ok ( ( ) ) ,
129
+ Err ( error) => match error {
130
+ RclrsError :: RclError { code, msg } => match code {
131
+ RclReturnCode :: WaitSetEmpty => Ok ( ( ) ) ,
132
+ _ => Err ( RclrsError :: RclError { code, msg } ) ,
133
+ } ,
134
+ _ => Err ( error) ,
135
+ } ,
136
+ } ;
127
137
128
138
// Remove any waitables that are no longer being used
129
139
for waitable in self . primitives . values_mut ( ) {
130
140
waitable. retain ( |w| w. in_use ( ) ) ;
131
141
}
132
142
133
- // For the remaining entities, check if they were activated and then run
134
- // the callback for those that were.
135
- for waiter in self . primitives . values_mut ( ) . flat_map ( |v| v) {
136
- if waiter. is_ready ( & self . handle . rcl_wait_set ) {
137
- f ( & mut * waiter. primitive ) ?;
143
+ // Do not check the readiness if an error was reported.
144
+ if !r. is_err ( ) {
145
+ // For the remaining entities, check if they were activated and then run
146
+ // the callback for those that were.
147
+ for waiter in self . primitives . values_mut ( ) . flat_map ( |v| v) {
148
+ if waiter. is_ready ( & self . handle . rcl_wait_set ) {
149
+ f ( & mut * waiter. primitive ) ?;
150
+ }
138
151
}
139
152
}
140
153
@@ -155,16 +168,7 @@ impl WaitSet {
155
168
) ;
156
169
}
157
170
158
- match r {
159
- Ok ( _) => Ok ( ( ) ) ,
160
- Err ( error) => match error {
161
- RclrsError :: RclError { code, msg } => match code {
162
- RclReturnCode :: WaitSetEmpty => Ok ( ( ) ) ,
163
- _ => Err ( RclrsError :: RclError { code, msg } ) ,
164
- } ,
165
- _ => Err ( error) ,
166
- } ,
167
- }
171
+ r
168
172
}
169
173
170
174
/// Get a count of the different kinds of entities in the wait set.
0 commit comments