Skip to content

Commit

Permalink
Refs #20629: Protect servers list
Browse files Browse the repository at this point in the history
Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
  • Loading branch information
cferreiragonz committed May 6, 2024
1 parent 9d71f4b commit 4d2244d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ DiscoveryDataBase::~DiscoveryDataBase()
void DiscoveryDataBase::add_server(
fastrtps::rtps::GuidPrefix_t server)
{
std::lock_guard<std::recursive_mutex> guard(mutex_);
EPROSIMA_LOG_INFO(DISCOVERY_DATABASE, "Server " << server << " added");
if (std::find(servers_.begin(), servers_.end(), server) == servers_.end())
{
Expand All @@ -73,6 +74,7 @@ void DiscoveryDataBase::add_server(
void DiscoveryDataBase::remove_server(
fastrtps::rtps::GuidPrefix_t server)
{
std::lock_guard<std::recursive_mutex> guard(mutex_);
auto remove_it = std::find(servers_.begin(), servers_.end(), server);
if (remove_it != servers_.end())
{
Expand Down Expand Up @@ -633,6 +635,7 @@ void DiscoveryDataBase::match_new_server_(
{
if (part.first == participant_prefix)
{
std::lock_guard<std::recursive_mutex> guard(mutex_);
bool resend_new_pdp = false;
for (auto& server: servers_)
{
Expand Down Expand Up @@ -2262,7 +2265,7 @@ std::map<eprosima::fastrtps::rtps::GUID_t, DiscoveryEndpointInfo>::iterator Disc
auto pit = participants_.find(it->first.guidPrefix);
if (pit == participants_.end())
{
EPROSIMA_LOG_ERROR(DISCOVERY_DATABASE, "Attempting to delete and orphan reader");
EPROSIMA_LOG_ERROR(DISCOVERY_DATABASE, "Attempting to delete an orphan reader");
// Returning error here could lead to an infinite loop
}
else
Expand Down

0 comments on commit 4d2244d

Please sign in to comment.