Skip to content

Commit

Permalink
Refs #20628: Check transport in function
Browse files Browse the repository at this point in the history
Signed-off-by: cferreiragonz <[email protected]>
  • Loading branch information
cferreiragonz committed Apr 3, 2024
1 parent c9dc0dc commit 3614ab0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 43 deletions.
40 changes: 19 additions & 21 deletions src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,7 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(
eprosima::shared_lock<eprosima::shared_mutex> disc_lock(mp_builtin->getDiscoveryMutex());

// TCP Clients need to handle logical ports
bool set_logicals = false;
for (auto& transportDescriptor : pattr.userTransports)
{
TCPTransportDescriptor* pT = dynamic_cast<TCPTransportDescriptor*>(transportDescriptor.get());
if (pT)
{
set_logicals = true;
break;
}
}
if (set_logicals)
if (handle_logical_ports_required())
{
for (eprosima::fastdds::rtps::RemoteServerAttributes& it : mp_builtin->m_DiscoveryServers)
{
Expand Down Expand Up @@ -869,16 +859,7 @@ void PDPClient::update_remote_servers_list()
eprosima::shared_lock<eprosima::shared_mutex> disc_lock(mp_builtin->getDiscoveryMutex());

// TCP Clients need to handle logical ports
bool set_logicals = false;
const RTPSParticipantAttributes& pattr = mp_RTPSParticipant->getRTPSParticipantAttributes();
for (auto& transportDescriptor : pattr.userTransports)
{
TCPTransportDescriptor* pT = dynamic_cast<TCPTransportDescriptor*>(transportDescriptor.get());
if (pT)
{
set_logicals = true;
}
}
bool set_logicals = handle_logical_ports_required();

for (const eprosima::fastdds::rtps::RemoteServerAttributes& it : mp_builtin->m_DiscoveryServers)
{
Expand Down Expand Up @@ -1469,6 +1450,23 @@ bool PDPClient::remove_remote_participant(
return false;
}

bool PDPClient::handle_logical_ports_required()
{
const RTPSParticipantAttributes& pattr = mp_RTPSParticipant->getRTPSParticipantAttributes();
bool set_logicals = false;
for (auto& transportDescriptor : pattr.userTransports)
{
TCPTransportDescriptor* pT = dynamic_cast<TCPTransportDescriptor*>(transportDescriptor.get());
if (pT)
{
set_logicals = true;
break;
}
}

return set_logicals;
}

} /* namespace rtps */
} /* namespace fastdds */
} /* namespace eprosima */
5 changes: 5 additions & 0 deletions src/cpp/rtps/builtin/discovery/participant/PDPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ class PDPClient : public PDP
void perform_builtin_endpoints_matching(
const ParticipantProxyData& pdata);

/**
* Check if the user transports of the RTPSParticipant requires logical ports (only TCP transport).
*/
bool handle_logical_ports_required();

/**
* TimedEvent for server synchronization:
* first stage: periodically resend the local RTPSParticipant information until
Expand Down
41 changes: 19 additions & 22 deletions src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,17 +517,7 @@ bool PDPServer::create_ds_pdp_reliable_endpoints(
eprosima::shared_lock<eprosima::shared_mutex> disc_lock(mp_builtin->getDiscoveryMutex());

// TCP Clients need to handle logical ports
bool set_logicals = false;
for (auto& transportDescriptor : pattr.userTransports)
{
TCPTransportDescriptor* pT = dynamic_cast<TCPTransportDescriptor*>(transportDescriptor.get());
if (pT)
{
set_logicals = true;
break;
}
}
if (set_logicals)
if (handle_logical_ports_required())
{
for (eprosima::fastdds::rtps::RemoteServerAttributes& it : mp_builtin->m_DiscoveryServers)
{
Expand Down Expand Up @@ -1213,17 +1203,7 @@ void PDPServer::update_remote_servers_list()
eprosima::shared_lock<eprosima::shared_mutex> disc_lock(mp_builtin->getDiscoveryMutex());

// TCP Clients need to handle logical ports
bool set_logicals = false;
const RTPSParticipantAttributes& pattr = mp_RTPSParticipant->getRTPSParticipantAttributes();
for (auto& transportDescriptor : pattr.userTransports)
{
TCPTransportDescriptor* pT = dynamic_cast<TCPTransportDescriptor*>(transportDescriptor.get());
if (pT)
{
set_logicals = true;
break;
}
}
bool set_logicals = handle_logical_ports_required();

for (const eprosima::fastdds::rtps::RemoteServerAttributes& it : mp_builtin->m_DiscoveryServers)
{
Expand Down Expand Up @@ -2111,6 +2091,23 @@ void PDPServer::release_change_from_writer(
endpoints->writer.writer_->release_change(change);
}

bool PDPServer::handle_logical_ports_required()
{
const RTPSParticipantAttributes& pattr = mp_RTPSParticipant->getRTPSParticipantAttributes();
bool set_logicals = false;
for (auto& transportDescriptor : pattr.userTransports)
{
TCPTransportDescriptor* pT = dynamic_cast<TCPTransportDescriptor*>(transportDescriptor.get());
if (pT)
{
set_logicals = true;
break;
}
}

return set_logicals;
}

} // namespace rtps
} // namespace fastdds
} // namespace eprosima
5 changes: 5 additions & 0 deletions src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ class PDPServer : public fastrtps::rtps::PDP
void match_reliable_pdp_endpoints(
const fastrtps::rtps::ParticipantProxyData& pdata);

/**
* Check if the user transports of the RTPSParticipant requires logical ports (only TCP transport).
*/
bool handle_logical_ports_required();

//! Server thread
eprosima::fastrtps::rtps::ResourceEvent resource_event_thread_;

Expand Down

0 comments on commit 3614ab0

Please sign in to comment.