diff --git a/src/cpp/subscriber/SubscriberHistory.cpp b/src/cpp/subscriber/SubscriberHistory.cpp index 42f3c9454ac..784336b6b7f 100644 --- a/src/cpp/subscriber/SubscriberHistory.cpp +++ b/src/cpp/subscriber/SubscriberHistory.cpp @@ -415,22 +415,20 @@ bool SubscriberHistory::remove_change_sub( } std::lock_guard guard(*mp_mutex); - if (mp_subImpl->getAttributes().topic.getTopicKind() != NO_KEY) + if (mp_subImpl->getAttributes().topic.getTopicKind() == WITH_KEY) { - t_m_Inst_Caches::iterator vit; - if (!find_key(change, &vit)) - { - return false; - } - bool found = false; - for (auto chit = vit->second.cache_changes.begin(); chit != vit->second.cache_changes.end(); ++chit) + t_m_Inst_Caches::iterator vit; + if (find_key(change, &vit)) { - if ((*chit)->sequenceNumber == change->sequenceNumber && (*chit)->writerGUID == change->writerGUID) + for (auto chit = vit->second.cache_changes.begin(); chit != vit->second.cache_changes.end(); ++chit) { - vit->second.cache_changes.erase(chit); - found = true; - break; + if ((*chit)->sequenceNumber == change->sequenceNumber && (*chit)->writerGUID == change->writerGUID) + { + vit->second.cache_changes.erase(chit); + found = true; + break; + } } } if (!found) @@ -438,11 +436,13 @@ bool SubscriberHistory::remove_change_sub( logWarning(SUBSCRIBER, "Change not found, something is wrong"); } } + if (remove_change(change)) { m_isHistoryFull = false; return true; } + return false; }