Skip to content
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