Skip to content

Commit

Permalink
fixed rcl_wait return error when timer cancelled (#1003) (#1006)
Browse files Browse the repository at this point in the history
* add error msg in rcl wait

Signed-off-by: kevin <kevin@floatic.io>

* error not set reason changed

Signed-off-by: kevin <kevin@floatic.io>

* change error msg

Signed-off-by: kevin <kevin@floatic.io>

* change error msg

Signed-off-by: kevin <kevin@floatic.io>

* rcl wait bug when timer is cancelled

Signed-off-by: kevin <kevin@floatic.io>

* change step of check timer cancelled

Signed-off-by: kevin <kevin@floatic.io>

* fixed rcl_wait when timer cancelled

Signed-off-by: kevin <kevin@floatic.io>

* removed empty line

Signed-off-by: ladianchad <qhrejddlvltm@gmail.com>

Signed-off-by: kevin <kevin@floatic.io>
Signed-off-by: ladianchad <qhrejddlvltm@gmail.com>
Co-authored-by: kevin <kevin@floatic.io>
(cherry picked from commit 4b125b1)

Co-authored-by: 정찬희 <60467877+ladianchad@users.noreply.github.com>
  • Loading branch information
mergify[bot] and ladianchad authored Sep 6, 2022
1 parent 243db89 commit b7cf928
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions rcl/src/rcl/wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,14 @@ rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout)
rmw_gcs->guard_conditions[gc_idx];
++(rmw_gcs->guard_condition_count);
}
bool is_canceled = false;
rcl_ret_t ret = rcl_timer_is_canceled(wait_set->timers[i], &is_canceled);
if (ret != RCL_RET_OK) {
return ret; // The rcl error state should already be set.
}
if (is_canceled) {
wait_set->timers[i] = NULL;
continue;
}
// use timer time to to set the rmw_wait timeout
// TODO(sloretz) fix spurious wake-ups on ROS_TIME timers with ROS_TIME enabled
int64_t timer_timeout = INT64_MAX;
ret = rcl_timer_get_time_until_next_call(wait_set->timers[i], &timer_timeout);
rcl_ret_t ret = rcl_timer_get_time_until_next_call(wait_set->timers[i], &timer_timeout);
if (ret == RCL_RET_TIMER_CANCELED) {
wait_set->timers[i] = NULL;
continue;
}
if (ret != RCL_RET_OK) {
return ret; // The rcl error state should already be set.
}
Expand Down

0 comments on commit b7cf928

Please sign in to comment.