Skip to content

Commit

Permalink
Fix lost responses issue (ros2#76)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Hoinkis <[email protected]>
  • Loading branch information
mossmaurice committed Jan 5, 2023
1 parent 56cc840 commit 57cc79a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions rmw_iceoryx_cpp/src/rmw_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ rmw_send_response(
rmw_iceoryx_cpp::serializeResponse(ros_response, &iceoryx_server_abstraction->type_supports_, payload_vector);
memcpy(responsePayload, payload_vector.data(), payload_vector.size());
}
/// @todo Why are the sleep before and after 'send()' needed? rmw_cyclonedds and rmw_fastrtps seem to do something similar in 'rmw_send_response'..
std::this_thread::sleep_for(std::chrono::milliseconds(100));
iceoryx_server->send(responsePayload).and_then([&]{
std::cout << "Server sent response!" << std::endl;
ret = RMW_RET_OK;
Expand All @@ -165,6 +167,7 @@ rmw_send_response(
RMW_SET_ERROR_MSG("rmw_send_response send error!");
ret = RMW_RET_ERROR;
});
std::this_thread::sleep_for(std::chrono::milliseconds(100));
})
.or_else(
[&](auto& error) {
Expand Down
11 changes: 5 additions & 6 deletions rmw_iceoryx_cpp/src/rmw_service_server_is_available.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ rmw_service_server_is_available(

std::this_thread::sleep_for(std::chrono::seconds(1));

*is_available = true;
// if(iceoryx_client->getConnectionState() == iox::ConnectionState::CONNECTED)
// {
// *is_available = true;
// }
if(iceoryx_client->getConnectionState() == iox::ConnectionState::CONNECTED)
{
*is_available = true;
}

/// @todo better to go through service discovery?
/// @todo Better to go through service discovery?
// iox::runtime::ServiceDiscovery serviceDiscovery;
// auto& searchItem = iceoryx_client->getServiceDescription();
// serviceDiscovery.findService( searchItem.getServiceIDString(),
Expand Down

0 comments on commit 57cc79a

Please sign in to comment.