Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21649] Correct iterator increment after erasing elements in connected_servers_list #5226

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,21 @@ void PDPClient::removeRemoteEndpoints(
eprosima::shared_lock<eprosima::shared_mutex> disc_lock(mp_builtin->getDiscoveryMutex());

// Verify if this participant is a server
for (auto it = connected_servers_.begin(); it != connected_servers_.end(); ++it)
auto it = connected_servers_.begin();
while (it != connected_servers_.end())
{
if (it->guidPrefix == pdata->m_guid.guidPrefix)
{
std::unique_lock<std::recursive_mutex> lock(*getMutex());
it = connected_servers_.erase(it);
is_server = true;
mp_sync->restart_timer(); // enable announcement and sync mechanism till this server reappears

// Avoid incrementing iterator after item removal
continue;
}

++it;
}
}

Expand Down
Loading