Skip to content

Commit 125ca72

Browse files
committed
Fix memory bug
Signed-off-by: Raül <raulojeda@eprosima.com>
1 parent a664246 commit 125ca72

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,12 +803,12 @@ void DiscoveryDataBase::update_participant_from_change_(
803803
update_change_and_unmatch_(ch, participant_info);
804804

805805
// If it is local and server we have to create virtual endpoints, except for our own server
806-
if (change_guid.guidPrefix != server_guid_prefix_ && change_data.is_local())
806+
if (change_guid.guidPrefix != server_guid_prefix_ && !change_data.is_client() && change_data.is_local())
807807
{
808808
// Match new server and create virtual endpoints
809809
// NOTE: match after having updated the change, so virtual endpoints are not discarded for having
810810
// an associated unalive participant
811-
match_new_server_(change_guid.guidPrefix, change_data.is_client() || change_data.is_superclient());
811+
match_new_server_(change_guid.guidPrefix, change_data.is_superclient());
812812
}
813813

814814
// Treat as a new participant found
@@ -832,8 +832,13 @@ void DiscoveryDataBase::update_participant_from_change_(
832832
// Update change
833833
update_change_and_unmatch_(ch, participant_info);
834834

835-
// NOTE: match after having updated the change in order to send the new Data(P)
836-
match_new_server_(change_guid.guidPrefix, change_data.is_client() || change_data.is_superclient());
835+
// If the participant changes to server local, virtual endpoints must be added
836+
// If it is local and server the only possibility is it was a remote server and it must be converted to local
837+
if (!change_data.is_client())
838+
{
839+
// NOTE: match after having updated the change in order to send the new Data(P)
840+
match_new_server_(change_guid.guidPrefix, change_data.is_superclient());
841+
}
837842

838843
// Treat as a new participant found
839844
new_updates_++;

test/blackbox/common/BlackboxTestsDiscovery.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,8 +2380,8 @@ TEST_P(Discovery, discovery_server_edp_messages_sent)
23802380
// Ensure that no additional Data(r/w) messages are sent by DS routine
23812381
std::this_thread::sleep_for(std::chrono::seconds(15));
23822382

2383-
EXPECT_EQ(num_data_r_w_sends_s1.load(std::memory_order::memory_order_seq_cst), 3u);
2384-
EXPECT_EQ(num_data_r_w_sends_s2.load(std::memory_order::memory_order_seq_cst), 3u);
2383+
EXPECT_EQ(num_data_r_w_sends_s1.load(std::memory_order::memory_order_seq_cst), 2u);
2384+
EXPECT_EQ(num_data_r_w_sends_s2.load(std::memory_order::memory_order_seq_cst), 2u);
23852385
}
23862386

23872387
// This is a regression test for Redmine #23088, which corrects the following data race in the discovery server:

0 commit comments

Comments
 (0)