Skip to content

Commit

Permalink
Refs #20181. New approach.
Browse files Browse the repository at this point in the history
Automatically sending DATA(p) when receiving a DATA(p) could lead to an infinite ping-pong between the two participants.
This resulted in some cases in the transport threads eating all CPU resources.

The new approach matches the discovered participant to the builtin non-secure PDP writer, so it will receive the DATA(p) of the local participant in the next periodic announcement.

Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Aug 26, 2024
1 parent 6f50326 commit a6842dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
39 changes: 9 additions & 30 deletions src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,31 +308,9 @@ bool PDPSimple::createPDPEndpoints()

endpoints = secure_endpoints;
endpoints->reader.listener_.reset(new PDPSecurityInitiatorListener(this,
[this, secure_endpoints](const ParticipantProxyData& participant_data)
[this](const ParticipantProxyData& participant_data)
{
assert(secure_endpoints == builtin_endpoints_.get());
std::lock_guard<fastdds::RecursiveTimedMutex> wlock(secure_endpoints->writer.writer_->getMutex());

CacheChange_t* change = nullptr;
secure_endpoints->writer.history_->get_earliest_change(&change);

if (change != nullptr)
{
std::vector<GUID_t> remote_readers;
LocatorList_t locators;

// Send discovery information through the non-secure PDP writer
remote_readers.emplace_back(participant_data.m_guid.guidPrefix, c_EntityId_SPDPReader);

fastdds::rtps::FakeWriter writer(getRTPSParticipant(), c_EntityId_SPDPWriter);

for (auto& locator : participant_data.metatraffic_locators.unicast)
{
locators.push_back(locator);
}

direct_send(getRTPSParticipant(), locators, remote_readers, *change, writer);
}
match_pdp_remote_endpoints(participant_data, false, true);
}));
}
else
Expand Down Expand Up @@ -581,7 +559,7 @@ void PDPSimple::assignRemoteEndpoints(
{
// This participant is not secure.
// Match PDP and other builtin endpoints.
match_pdp_remote_endpoints(*pdata, false);
match_pdp_remote_endpoints(*pdata, false, false);
assign_low_level_remote_endpoints(*pdata, false);
}
}
Expand Down Expand Up @@ -624,7 +602,7 @@ void PDPSimple::notifyAboveRemoteEndpoints(
{
if (notify_secure_endpoints)
{
match_pdp_remote_endpoints(pdata, true);
match_pdp_remote_endpoints(pdata, true, false);
}
else
{
Expand All @@ -637,7 +615,7 @@ void PDPSimple::notifyAboveRemoteEndpoints(
notify_and_maybe_ignore_new_participant(part_data, ignored);
if (!ignored)
{
match_pdp_remote_endpoints(*part_data, false);
match_pdp_remote_endpoints(*part_data, false, false);
assign_low_level_remote_endpoints(*part_data, false);
}
}
Expand All @@ -647,7 +625,8 @@ void PDPSimple::notifyAboveRemoteEndpoints(

void PDPSimple::match_pdp_remote_endpoints(
const ParticipantProxyData& pdata,
bool notify_secure_endpoints)
bool notify_secure_endpoints,
bool writer_only)
{
#if !HAVE_SECURITY
static_cast<void>(notify_secure_endpoints);
Expand Down Expand Up @@ -684,7 +663,7 @@ void PDPSimple::match_pdp_remote_endpoints(
}
#endif // HAVE_SECURITY

if (0 != (endp & pdp_writer_mask))
if (!writer_only && (0 != (endp & pdp_writer_mask)))
{
auto temp_writer_data = get_temporary_writer_proxies_pool().get();

Expand Down Expand Up @@ -742,7 +721,7 @@ void PDPSimple::match_pdp_remote_endpoints(
writer->matched_reader_add_edp(*temp_reader_data);
}

if (dds::BEST_EFFORT_RELIABILITY_QOS == reliability_kind)
if (!writer_only && (dds::BEST_EFFORT_RELIABILITY_QOS == reliability_kind))
{
endpoints->writer.writer_->unsent_changes_reset();
}
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDPSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class PDPSimple : public PDP

void match_pdp_remote_endpoints(
const ParticipantProxyData& pdata,
bool notify_secure_endpoints);
bool notify_secure_endpoints,
bool writer_only);

void assign_low_level_remote_endpoints(
const ParticipantProxyData& pdata,
Expand Down

0 comments on commit a6842dc

Please sign in to comment.