From 8ebd4d95f19eb7e1fe9b556f3d730ec469c93a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 13 Jun 2018 06:27:11 +0200 Subject: [PATCH] Refs #2821. Fixing error storing history record --- include/fastrtps/rtps/reader/WriterProxy.h | 2 +- .../builtin/discovery/endpoint/EDPSimple.cpp | 8 ++++ .../discovery/participant/PDPSimple.cpp | 2 + src/cpp/rtps/builtin/liveliness/WLP.cpp | 2 + src/cpp/rtps/reader/RTPSReader.cpp | 38 +++++++++++-------- src/cpp/rtps/reader/StatefulReader.cpp | 6 +-- src/cpp/rtps/reader/WriterProxy.cpp | 3 +- src/cpp/rtps/security/SecurityManager.cpp | 4 ++ 8 files changed, 44 insertions(+), 21 deletions(-) diff --git a/include/fastrtps/rtps/reader/WriterProxy.h b/include/fastrtps/rtps/reader/WriterProxy.h index 4049ff5435e..4897c009460 100644 --- a/include/fastrtps/rtps/reader/WriterProxy.h +++ b/include/fastrtps/rtps/reader/WriterProxy.h @@ -69,7 +69,7 @@ namespace eprosima * Set initial value for last acked sequence number. * @param[in] seqNum last acked sequence number. */ - void loaded_from_storage(const SequenceNumber_t& seqNum); + void loaded_from_storage_nts(const SequenceNumber_t& seqNum); /** * Get the maximum sequenceNumber received from this Writer. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index f7ea22018db..a737dce9346 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -671,6 +671,7 @@ void EDPSimple::assignRemoteEndpoints(const ParticipantProxyData& pdata) RemoteWriterAttributes watt(pdata.m_VendorId); watt.guid.guidPrefix = pdata.m_guid.guidPrefix; watt.guid.entityId = c_EntityId_SEDPPubWriter; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata.m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata.m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; @@ -704,6 +705,7 @@ void EDPSimple::assignRemoteEndpoints(const ParticipantProxyData& pdata) RemoteWriterAttributes watt(pdata.m_VendorId); watt.guid.guidPrefix = pdata.m_guid.guidPrefix; watt.guid.entityId = c_EntityId_SEDPSubWriter; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata.m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata.m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; @@ -738,6 +740,7 @@ void EDPSimple::assignRemoteEndpoints(const ParticipantProxyData& pdata) WriterProxyData watt; watt.guid().guidPrefix = pdata.m_guid.guidPrefix; watt.guid().entityId = sedp_builtin_publications_secure_writer; + watt.persistence_guid(watt.guid()); watt.unicastLocatorList(pdata.m_metatrafficUnicastLocatorList); watt.multicastLocatorList(pdata.m_metatrafficMulticastLocatorList); watt.m_qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; @@ -783,6 +786,7 @@ void EDPSimple::assignRemoteEndpoints(const ParticipantProxyData& pdata) WriterProxyData watt; watt.guid().guidPrefix = pdata.m_guid.guidPrefix; watt.guid().entityId = sedp_builtin_subscriptions_secure_writer; + watt.persistence_guid(watt.guid()); watt.unicastLocatorList(pdata.m_metatrafficUnicastLocatorList); watt.multicastLocatorList(pdata.m_metatrafficMulticastLocatorList); watt.m_qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; @@ -837,6 +841,7 @@ void EDPSimple::removeRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt; watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = c_EntityId_SEDPPubWriter; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; @@ -869,6 +874,7 @@ void EDPSimple::removeRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt; watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = c_EntityId_SEDPSubWriter; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; @@ -903,6 +909,7 @@ void EDPSimple::removeRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt; watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = sedp_builtin_publications_secure_writer; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; @@ -944,6 +951,7 @@ void EDPSimple::removeRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt; watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = sedp_builtin_subscriptions_secure_writer; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp index 2902c2d04dc..55301413604 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp @@ -606,6 +606,7 @@ void PDPSimple::assignRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt(pdata->m_VendorId); watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = c_EntityId_SPDPWriter; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = BEST_EFFORT; @@ -657,6 +658,7 @@ void PDPSimple::removeRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt; watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = c_EntityId_SPDPWriter; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.reliabilityKind = BEST_EFFORT; diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index 7b04f68734f..73841b3ed76 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -165,6 +165,7 @@ bool WLP::assignRemoteEndpoints(const ParticipantProxyData& pdata) RemoteWriterAttributes watt(pdata.m_VendorId); watt.guid.guidPrefix = pdata.m_guid.guidPrefix; watt.guid.entityId = c_EntityId_WriterLiveliness; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata.m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata.m_metatrafficMulticastLocatorList; watt.endpoint.topicKind = WITH_KEY; @@ -211,6 +212,7 @@ void WLP::removeRemoteEndpoints(ParticipantProxyData* pdata) RemoteWriterAttributes watt; watt.guid.guidPrefix = pdata->m_guid.guidPrefix; watt.guid.entityId = c_EntityId_WriterLiveliness; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = pdata->m_metatrafficUnicastLocatorList; watt.endpoint.multicastLocatorList = pdata->m_metatrafficMulticastLocatorList; watt.endpoint.topicKind = WITH_KEY; diff --git a/src/cpp/rtps/reader/RTPSReader.cpp b/src/cpp/rtps/reader/RTPSReader.cpp index 1b106d02f61..f6f96c3ed4b 100644 --- a/src/cpp/rtps/reader/RTPSReader.cpp +++ b/src/cpp/rtps/reader/RTPSReader.cpp @@ -125,21 +125,24 @@ void RTPSReader::remove_persistence_guid(const RemoteWriterAttributes& wdata) SequenceNumber_t RTPSReader::update_last_notified(const GUID_t& guid, const SequenceNumber_t& seq) { - SequenceNumber_t ret_val(0, 0); + SequenceNumber_t ret_val; std::lock_guard guard(*mp_mutex); + GUID_t guid_to_look = guid; auto p_guid = persistence_guid_map_.find(guid); if (p_guid != persistence_guid_map_.end()) { - auto p_seq = history_record_.find(p_guid->second); - if (p_seq != history_record_.end()) - { - ret_val = p_seq->second; - } + guid_to_look = p_guid->second; + } - if (ret_val < seq) - { - set_last_notified(p_guid->second, seq); - } + auto p_seq = history_record_.find(guid_to_look); + if (p_seq != history_record_.end()) + { + ret_val = p_seq->second; + } + + if (ret_val < seq) + { + set_last_notified(guid_to_look, seq); } return ret_val; @@ -147,16 +150,19 @@ SequenceNumber_t RTPSReader::update_last_notified(const GUID_t& guid, const Sequ SequenceNumber_t RTPSReader::get_last_notified(const GUID_t& guid) const { - SequenceNumber_t ret_val(0, 0); + SequenceNumber_t ret_val; std::lock_guard guard(*mp_mutex); + GUID_t guid_to_look = guid; auto p_guid = persistence_guid_map_.find(guid); if (p_guid != persistence_guid_map_.end()) { - auto p_seq = history_record_.find(p_guid->second); - if (p_seq != history_record_.end()) - { - ret_val = p_seq->second; - } + guid_to_look = p_guid->second; + } + + auto p_seq = history_record_.find(guid_to_look); + if (p_seq != history_record_.end()) + { + ret_val = p_seq->second; } return ret_val; diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 8d321b98ae4..19bd97c854c 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -75,12 +75,12 @@ bool StatefulReader::matched_writer_add(const RemoteWriterAttributes& wdata) } } WriterProxy* wp = new WriterProxy(wdata, this); - + wp->mp_initialAcknack->restart_timer(); - matched_writers.push_back(wp); add_persistence_guid(wdata); - wp->loaded_from_storage(get_last_notified(wdata.guid)); + wp->loaded_from_storage_nts(get_last_notified(wdata.guid)); + matched_writers.push_back(wp); logInfo(RTPS_READER,"Writer Proxy " <m_att.guid <<" added to " <getGuid().entityId); } -void WriterProxy::loaded_from_storage(const SequenceNumber_t& seqNum) +void WriterProxy::loaded_from_storage_nts(const SequenceNumber_t& seqNum) { lastNotified_ = seqNum; + changesFromWLowMark_ = seqNum; } void WriterProxy::missing_changes_update(const SequenceNumber_t& seqNum) diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 77184acf6ce..1eda463a29b 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -1628,6 +1628,7 @@ void SecurityManager::match_builtin_endpoints(const ParticipantProxyData& partic RemoteWriterAttributes watt(participant_data.m_VendorId); watt.guid.guidPrefix = participant_data.m_guid.guidPrefix; watt.guid.entityId = participant_stateless_message_writer_entity_id; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = participant_data.m_metatrafficUnicastLocatorList; watt.endpoint.reliabilityKind = BEST_EFFORT; participant_stateless_message_reader_->matched_writer_add(watt); @@ -1651,6 +1652,7 @@ void SecurityManager::match_builtin_endpoints(const ParticipantProxyData& partic RemoteWriterAttributes watt(participant_data.m_VendorId); watt.guid.guidPrefix = participant_data.m_guid.guidPrefix; watt.guid.entityId = participant_volatile_message_secure_writer_entity_id; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = participant_data.m_metatrafficUnicastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; watt.endpoint.durabilityKind = VOLATILE; @@ -1681,6 +1683,7 @@ void SecurityManager::unmatch_builtin_endpoints(const ParticipantProxyData& part RemoteWriterAttributes watt; watt.guid.guidPrefix = participant_data.m_guid.guidPrefix; watt.guid.entityId = participant_stateless_message_writer_entity_id; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = participant_data.m_metatrafficUnicastLocatorList; watt.endpoint.reliabilityKind = BEST_EFFORT; participant_stateless_message_reader_->matched_writer_remove(watt); @@ -1704,6 +1707,7 @@ void SecurityManager::unmatch_builtin_endpoints(const ParticipantProxyData& part RemoteWriterAttributes watt; watt.guid.guidPrefix = participant_data.m_guid.guidPrefix; watt.guid.entityId = participant_volatile_message_secure_writer_entity_id; + watt.endpoint.persistence_guid = watt.guid; watt.endpoint.unicastLocatorList = participant_data.m_metatrafficUnicastLocatorList; watt.endpoint.reliabilityKind = RELIABLE; watt.endpoint.durabilityKind = VOLATILE;