Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the hasData checks for non-blocking wait 'timeout' higher #158

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions rmw_fastrtps_cpp/src/rmw_wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ rmw_wait(
// after we check, it will be caught on the next call to this function).
lock.unlock();

// Even if this was a non-blocking wait, signal a timeout if there's no data.
// This makes the return behavior consistent with rcl expectations for zero timeout value.
// Do this before detaching the listeners because the data gets cleared for guard conditions.
bool hasData = check_waitset_for_data(subscriptions, guard_conditions, services, clients);
if (!hasData && wait_timeout && wait_timeout->sec == 0 && wait_timeout->nsec == 0) {
timeout = true;
}

for (size_t i = 0; i < subscriptions->subscriber_count; ++i) {
void * data = subscriptions->subscribers[i];
CustomSubscriberInfo * custom_subscriber_info = static_cast<CustomSubscriberInfo *>(data);
Expand Down Expand Up @@ -231,11 +239,6 @@ rmw_wait(
}
}
}
// Make timeout behavior consistent with rcl expectations for zero timeout value
bool hasData = check_waitset_for_data(subscriptions, guard_conditions, services, clients);
if (!hasData && wait_timeout && wait_timeout->sec == 0 && wait_timeout->nsec == 0) {
return RMW_RET_TIMEOUT;
}

return timeout ? RMW_RET_TIMEOUT : RMW_RET_OK;
}
Expand Down