Skip to content

Commit af68904

Browse files
committed
Refs #22056: Avoid clearing same channel multiple times
Signed-off-by: cferreiragonz <[email protected]>
1 parent a4f7c2b commit af68904

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/cpp/rtps/transport/TCPTransportInterface.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void TCPTransportInterface::clean()
191191

192192
{
193193
std::vector<std::shared_ptr<TCPChannelResource>> channels;
194+
std::vector<eprosima::fastdds::rtps::Locator> delete_channels;
194195

195196
{
196197
std::unique_lock<std::mutex> scopedLock(sockets_map_mutex_);
@@ -200,10 +201,22 @@ void TCPTransportInterface::clean()
200201

201202
for (auto& channel : channel_resources_)
202203
{
203-
channels.push_back(channel.second);
204+
if (std::find(channels.begin(), channels.end(), channel.second) == channels.end())
205+
{
206+
channels.push_back(channel.second);
207+
}
208+
else
209+
{
210+
delete_channels.push_back(channel.first);
211+
}
204212
}
205213
}
206214

215+
for (auto& delete_channel : delete_channels)
216+
{
217+
channel_resources_.erase(delete_channel);
218+
}
219+
207220
for (auto& channel : channels)
208221
{
209222
if (channel->connection_established())

0 commit comments

Comments
 (0)