Skip to content

Commit

Permalink
Refs #22623: Allow TCP reconnections
Browse files Browse the repository at this point in the history
Signed-off-by: cferreiragonz <[email protected]>
  • Loading branch information
cferreiragonz committed Jan 16, 2025
1 parent 1ee0b51 commit 771fbfe
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/cpp/rtps/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,15 @@ ResponseCode TCPTransportInterface::bind_socket(
decltype(channel_resources_)::value_type{channel->locator(), channel});
if (false == insert_ret.second)
{
// There is an existing channel that can be used. Force the Client to close unnecessary socket
ret = RETCODE_SERVER_ERROR;
if (insert_ret.first->second->connection_established())
{
// There is an existing channel that can be used. Force the Client to close unnecessary socket
ret = RETCODE_SERVER_ERROR;
}
else
{
insert_ret.first->second = channel;
}
}

std::vector<fastdds::rtps::IPFinder::info_IP> local_interfaces;
Expand All @@ -320,7 +327,12 @@ ResponseCode TCPTransportInterface::bind_socket(
for (auto& interface_it : local_interfaces)
{
IPLocator::setIPv4(local_locator, interface_it.locator);
channel_resources_.insert(decltype(channel_resources_)::value_type{local_locator, channel});
const auto insert_ret_local = channel_resources_.insert(
decltype(channel_resources_)::value_type{local_locator, channel});
if (!insert_ret_local.first->second->connection_established())
{
insert_ret_local.first->second = channel;
}
}
}
return ret;
Expand Down

0 comments on commit 771fbfe

Please sign in to comment.