Skip to content

Commit 933e4ef

Browse files
committed
Refs #20629: Avoid SC matching with remote servers
Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
1 parent 848f9cb commit 933e4ef

3 files changed

Lines changed: 33 additions & 28 deletions

File tree

src/cpp/rtps/builtin/discovery/database/DiscoveryDataBase.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ void DiscoveryDataBase::create_participant_from_change_(
610610
}
611611

612612
void DiscoveryDataBase::match_new_server_(
613-
eprosima::fastrtps::rtps::GuidPrefix_t& participant_prefix)
613+
eprosima::fastrtps::rtps::GuidPrefix_t& participant_prefix,
614+
bool is_superclient)
614615
{
615616
// Send Our DATA(p) to the new participant.
616617
// If this is not done, our data could be skipped afterwards because of a gap sent in newer DATA(p)s,
@@ -619,40 +620,43 @@ void DiscoveryDataBase::match_new_server_(
619620
assert(our_data_it != participants_.end());
620621
add_pdp_to_send_(our_data_it->second.change());
621622

622-
// To obtain a mesh topology, we need to:
623-
// - Make all known servers relevant to the new server
624-
// - Make the new server relevant to all known servers
625-
// - Send DATA(p) of all known servers to the new server
626-
// - Send Data(p) of the new server to all other servers
627-
for (auto& part : participants_)
623+
if (!is_superclient)
628624
{
629-
if (part.first != server_guid_prefix_ && !part.second.is_client())
625+
// To obtain a mesh topology with servers, we need to:
626+
// - Make all known servers relevant to the new server
627+
// - Make the new server relevant to all known servers
628+
// - Send DATA(p) of all known servers to the new server
629+
// - Send Data(p) of the new server to all other servers
630+
for (auto& part : participants_)
630631
{
631-
if (part.first == participant_prefix)
632+
if (part.first != server_guid_prefix_ && !part.second.is_client() && !part.second.is_superclient())
632633
{
633-
bool resend_new_pdp = false;
634-
for (auto& server: servers_)
634+
if (part.first == participant_prefix)
635635
{
636-
if (server != participant_prefix)
636+
bool resend_new_pdp = false;
637+
for (auto& server: servers_)
638+
{
639+
if (server != participant_prefix)
640+
{
641+
// Make all known servers relevant to the new server, but not matched
642+
part.second.add_or_update_ack_participant(server, false);
643+
resend_new_pdp = true;
644+
}
645+
}
646+
if (resend_new_pdp)
637647
{
638-
// Make all known servers relevant to the new server, but not matched
639-
part.second.add_or_update_ack_participant(server, false);
640-
resend_new_pdp = true;
648+
// Send DATA(p) of the new server to all other servers.
649+
add_pdp_to_send_(part.second.change());
641650
}
642651
}
643-
if (resend_new_pdp)
652+
else
644653
{
645-
// Send DATA(p) of the new server to all other servers.
654+
// Make the new server relevant to all known servers
655+
part.second.add_or_update_ack_participant(participant_prefix, false);
656+
// Send DATA(p) of all known servers to the new participant
646657
add_pdp_to_send_(part.second.change());
647658
}
648659
}
649-
else
650-
{
651-
// Make the new server relevant to all known servers
652-
part.second.add_or_update_ack_participant(participant_prefix, false);
653-
// Send DATA(p) of all known servers to the new participant
654-
add_pdp_to_send_(part.second.change());
655-
}
656660
}
657661
}
658662
// The resources needed for TCP new connections are created during the matching process when the
@@ -768,7 +772,7 @@ void DiscoveryDataBase::create_new_participant_from_change_(
768772
!ret.first->second.is_client() && ret.first->second.is_local())
769773
{
770774
// Match new server and create virtual endpoints
771-
match_new_server_(change_guid.guidPrefix);
775+
match_new_server_(change_guid.guidPrefix, change_data.is_superclient());
772776
}
773777
}
774778
else
@@ -795,7 +799,7 @@ void DiscoveryDataBase::update_participant_from_change_(
795799
// If it is local and server the only possibility is it was a remote server and it must be converted to local
796800
if (!change_data.is_client())
797801
{
798-
match_new_server_(change_guid.guidPrefix);
802+
match_new_server_(change_guid.guidPrefix, change_data.is_superclient());
799803
}
800804

801805
// Update the change data

src/cpp/rtps/builtin/discovery/database/DiscoveryDataBase.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ class DiscoveryDataBase
396396
// Functions related with create_participant_from_change_
397397

398398
void match_new_server_(
399-
eprosima::fastrtps::rtps::GuidPrefix_t& participant_prefix);
399+
eprosima::fastrtps::rtps::GuidPrefix_t& participant_prefix,
400+
bool is_superclient);
400401

401402
void create_virtual_endpoints_(
402403
eprosima::fastrtps::rtps::GuidPrefix_t& participant_prefix);

src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void PDPServerListener::onNewCacheChangeAdded(
313313

314314
// All local builtins are connected, the database will avoid any EDP DATA to be send before having PDP
315315
// DATA acknowledgement. Non-local SERVERs will also be connected
316-
if ( pdata && (is_local || !is_client))
316+
if (pdata && (is_local || (!is_client && !is_superclient)))
317317
{
318318
pdp_server()->assignRemoteEndpoints(pdata);
319319
}

0 commit comments

Comments
 (0)