@@ -275,7 +275,7 @@ Executor::spin_until_future_complete_impl(
275275 if (spinning.exchange (true )) {
276276 throw std::runtime_error (" spin_until_future_complete() called while already spinning" );
277277 }
278- RCPPUTILS_SCOPE_EXIT (this ->spinning .store (false ); );
278+ RCPPUTILS_SCOPE_EXIT (this ->spinning .store (false );wait_result_. reset (); );
279279 while (rclcpp::ok (this ->context_ ) && spinning.load ()) {
280280 // Do one item of work.
281281 spin_once_impl (timeout_left);
@@ -364,7 +364,7 @@ Executor::spin_some_impl(std::chrono::nanoseconds max_duration, bool exhaustive)
364364 if (spinning.exchange (true )) {
365365 throw std::runtime_error (" spin_some() called while already spinning" );
366366 }
367- RCPPUTILS_SCOPE_EXIT (this ->spinning .store (false ); );
367+ RCPPUTILS_SCOPE_EXIT (this ->spinning .store (false );wait_result_. reset (); );
368368
369369 // clear the wait result and wait for work without blocking to collect the work
370370 // for the first time
@@ -431,7 +431,7 @@ Executor::spin_once(std::chrono::nanoseconds timeout)
431431 if (spinning.exchange (true )) {
432432 throw std::runtime_error (" spin_once() called while already spinning" );
433433 }
434- RCPPUTILS_SCOPE_EXIT (this ->spinning .store (false ); );
434+ RCPPUTILS_SCOPE_EXIT (this ->spinning .store (false );wait_result_. reset (); );
435435 spin_once_impl (timeout);
436436}
437437
@@ -885,8 +885,6 @@ Executor::get_next_executable(AnyExecutable & any_executable, std::chrono::nanos
885885 // Wait for subscriptions or timers to work on
886886 wait_for_work (timeout);
887887 if (!spinning.load ()) {
888- // Clear wait result to release ownership of entity
889- wait_result_.reset ();
890888 return false ;
891889 }
892890 // Try again
0 commit comments