always check if the service is available, even if the graph event wasn't triggered (#262)

* always check if the service is available, even if the graph event wasn't triggered

* more descriptive comment

* Even more descriptive in case the link ever breaks
This commit is contained in:
William Woodall 2016-10-28 18:31:15 -07:00 committed by GitHub
parent d158dd46db
commit 7494350ad2

View file

@ -96,10 +96,13 @@ ClientBase::wait_for_service_nanoseconds(std::chrono::nanoseconds timeout)
return false;
}
node_ptr->wait_for_graph_change(event, time_to_wait);
if (event->check_and_clear()) {
if (this->service_is_ready()) {
return true;
}
event->check_and_clear(); // reset the event
// always check if the service is ready, even if the graph event wasn't triggered
// this is needed to avoid a race condition that is specific to the Connext RMW implementation
// (see https://github.com/ros2/rmw_connext/issues/201)
if (this->service_is_ready()) {
return true;
}
// server is not ready, loop if there is time left
time_to_wait = timeout - (std::chrono::steady_clock::now() - start);