From 421527a508afab6e8493137d346ee4b2bef70c02 Mon Sep 17 00:00:00 2001 From: Iker Luengo Date: Wed, 12 Feb 2020 16:34:38 +0100 Subject: [PATCH] Delete history_record when endpoint is unmatched --- src/cpp/rtps/reader/RTPSReader.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cpp/rtps/reader/RTPSReader.cpp b/src/cpp/rtps/reader/RTPSReader.cpp index 20ac468fe01..541f1ffb9fb 100644 --- a/src/cpp/rtps/reader/RTPSReader.cpp +++ b/src/cpp/rtps/reader/RTPSReader.cpp @@ -106,13 +106,15 @@ void RTPSReader::add_persistence_guid(const RemoteWriterAttributes& wdata) void RTPSReader::remove_persistence_guid(const RemoteWriterAttributes& wdata) { std::lock_guard guard(mp_mutex); + GUID_t persistence_guid = persistence_guid_map_[wdata.guid]; persistence_guid_map_.erase(wdata.guid); - auto count = --persistence_guid_count_[wdata.endpoint.persistence_guid]; - if (count == 0) + auto count = --persistence_guid_count_[persistence_guid]; + if (count <= 0) { if (m_att.durabilityKind < TRANSIENT) { - history_record_.erase(wdata.endpoint.persistence_guid); + history_record_.erase(persistence_guid); + persistence_guid_count_.erase(persistence_guid); } } }