Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly update memory policy on writers and readers [11348] #1931

Merged
merged 5 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,16 +1483,16 @@ std::shared_ptr<IPayloadPool> DataWriterImpl::get_payload_pool()
{
if (!payload_pool_)
{
PoolConfig config = PoolConfig::from_history_attributes(history_.m_att);

// When the user requested PREALLOCATED_WITH_REALLOC, but we know the type cannot
// grow, we translate the policy into bare PREALLOCATED
if (PREALLOCATED_WITH_REALLOC_MEMORY_MODE == config.memory_policy &&
if (PREALLOCATED_WITH_REALLOC_MEMORY_MODE == history_.m_att.memoryPolicy &&
(type_->is_bounded() || type_->is_plain()))
{
config.memory_policy = PREALLOCATED_MEMORY_MODE;
history_.m_att.memoryPolicy = PREALLOCATED_MEMORY_MODE;
}

PoolConfig config = PoolConfig::from_history_attributes(history_.m_att);

// Avoid calling the serialization size functors on PREALLOCATED mode
fixed_payload_size_ = config.memory_policy == PREALLOCATED_MEMORY_MODE ? config.payload_initial_size : 0u;

Expand Down
10 changes: 9 additions & 1 deletion src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,15 @@ DataReaderListener* DataReaderImpl::get_listener_for(

std::shared_ptr<IPayloadPool> DataReaderImpl::get_payload_pool()
{
PoolConfig config = PoolConfig::from_history_attributes(history_.m_att );
// When the user requested PREALLOCATED_WITH_REALLOC, but we know the type cannot
// grow, we translate the policy into bare PREALLOCATED
if (PREALLOCATED_WITH_REALLOC_MEMORY_MODE == history_.m_att.memoryPolicy &&
(type_->is_bounded() || type_->is_plain()))
{
history_.m_att.memoryPolicy = PREALLOCATED_MEMORY_MODE;
}

PoolConfig config = PoolConfig::from_history_attributes(history_.m_att);

if (!payload_pool_)
{
Expand Down
7 changes: 7 additions & 0 deletions test/blackbox/api/dds-pim/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,13 @@ class PubSubWriter
return *this;
}

PubSubWriter& mem_policy(
const eprosima::fastrtps::rtps::MemoryManagementPolicy mem_policy)
{
datawriter_qos_.endpoint().history_memory_policy = mem_policy;
return *this;
}

PubSubWriter& deadline_period(
const eprosima::fastrtps::Duration_t deadline_period)
{
Expand Down
7 changes: 7 additions & 0 deletions test/blackbox/api/fastrtps_deprecated/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ class PubSubWriter
return *this;
}

PubSubWriter& mem_policy(
const eprosima::fastrtps::rtps::MemoryManagementPolicy mem_policy)
{
publisher_attr_.historyMemoryPolicy = mem_policy;
return *this;
}

PubSubWriter& deadline_period(
const eprosima::fastrtps::Duration_t deadline_period)
{
Expand Down
Loading