Skip to content

Commit

Permalink
Protect asio exception hotfix (#4527)
Browse files Browse the repository at this point in the history
* Refs #20599: Handle error code before function call

Signed-off-by: cferreiragonz <[email protected]>

* Apply suggestion

Co-authored-by: Miguel Company <[email protected]>

---------

Signed-off-by: cferreiragonz <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
(cherry picked from commit 08193d5)

# Conflicts:
#	src/cpp/rtps/transport/TCPTransportInterface.cpp
  • Loading branch information
cferreiragonz authored and elianalf committed Mar 20, 2024
1 parent ee15301 commit fc323e7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/cpp/rtps/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,40 @@ void TCPTransportInterface::clean()
}
}

Locator TCPTransportInterface::remote_endpoint_to_locator(
const std::shared_ptr<TCPChannelResource>& channel) const
{
Locator locator;
asio::error_code ec;
auto endpoint = channel->remote_endpoint(ec);
if (ec)
{
LOCATOR_INVALID(locator);
}
else
{
endpoint_to_locator(endpoint, locator);
}
return locator;
}

Locator TCPTransportInterface::local_endpoint_to_locator(
const std::shared_ptr<TCPChannelResource>& channel) const
{
Locator locator;
asio::error_code ec;
auto endpoint = channel->local_endpoint(ec);
if (ec)
{
LOCATOR_INVALID(locator);
}
else
{
endpoint_to_locator(endpoint, locator);
}
return locator;
}

void TCPTransportInterface::bind_socket(
std::shared_ptr<TCPChannelResource>& channel)
{
Expand Down

0 comments on commit fc323e7

Please sign in to comment.