From 0588ba09e96a2a9d62b6f0752576490be716a406 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 5 Jun 2024 10:46:23 +0200 Subject: [PATCH] Refs #21121: Avoid unsetting payload_owner Signed-off-by: cferreiragonz --- src/cpp/rtps/reader/StatefulReader.cpp | 11 ++--------- src/cpp/rtps/reader/StatelessReader.cpp | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 9adbb233a2b..b04c12b07af 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -624,13 +624,10 @@ bool StatefulReader::processDataMsg( // Copy metadata to reserved change change_to_add->copy_not_memcpy(change); - // Ask payload pool to copy the payload - IPayloadPool* payload_owner = change->payload_owner(); - if (is_datasharing_compatible_ && datasharing_listener_->writer_is_matched(change->writerGUID)) { // We may receive the change from the listener (with owner a ReaderPool) or intraprocess (with owner a WriterPool) - ReaderPool* datasharing_pool = dynamic_cast(payload_owner); + ReaderPool* datasharing_pool = dynamic_cast(change->payload_owner()); if (!datasharing_pool) { datasharing_pool = datasharing_listener_->get_pool_for_writer(change->writerGUID).get(); @@ -644,11 +641,7 @@ bool StatefulReader::processDataMsg( } datasharing_pool->get_datasharing_change(change->serializedPayload, *change_to_add); } - else if (payload_pool_->get_payload(change->serializedPayload, change_to_add->serializedPayload)) - { - change->payload_owner(payload_owner); - } - else + else if (!payload_pool_->get_payload(change->serializedPayload, change_to_add->serializedPayload)) { EPROSIMA_LOG_WARNING(RTPS_MSG_IN, IDSTRING "Problem copying CacheChange, received data is: " << change->serializedPayload.length << " bytes and max size in reader " diff --git a/src/cpp/rtps/reader/StatelessReader.cpp b/src/cpp/rtps/reader/StatelessReader.cpp index 0b5d67364c1..2b708343384 100644 --- a/src/cpp/rtps/reader/StatelessReader.cpp +++ b/src/cpp/rtps/reader/StatelessReader.cpp @@ -612,9 +612,6 @@ bool StatelessReader::processDataMsg( // Copy metadata to reserved change change_to_add->copy_not_memcpy(change); - // Ask payload pool to copy the payload - IPayloadPool* payload_owner = change->payload_owner(); - bool is_datasharing = std::any_of(matched_writers_.begin(), matched_writers_.end(), [&change](const RemoteWriterInfo_t& writer) { @@ -624,7 +621,7 @@ bool StatelessReader::processDataMsg( if (is_datasharing) { //We may receive the change from the listener (with owner a ReaderPool) or intraprocess (with owner a WriterPool) - ReaderPool* datasharing_pool = dynamic_cast(payload_owner); + ReaderPool* datasharing_pool = dynamic_cast(change->payload_owner()); if (!datasharing_pool) { datasharing_pool = datasharing_listener_->get_pool_for_writer(change->writerGUID).get(); @@ -638,11 +635,7 @@ bool StatelessReader::processDataMsg( } datasharing_pool->get_datasharing_change(change->serializedPayload, *change_to_add); } - else if (payload_pool_->get_payload(change->serializedPayload, change_to_add->serializedPayload)) - { - change->payload_owner(payload_owner); - } - else + else if (!payload_pool_->get_payload(change->serializedPayload, change_to_add->serializedPayload)) { EPROSIMA_LOG_WARNING(RTPS_MSG_IN, IDSTRING "Problem copying CacheChange, received data is: " << change->serializedPayload.length << " bytes and max size in reader "