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

[21272] Fix assertion in TopicPayloadPool::release_history #5008

Merged
merged 2 commits into from
Jul 1, 2024
Merged
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
29 changes: 14 additions & 15 deletions src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ ReturnCode_t DataWriterImpl::enable()
topic_att, type_->m_typeSize, qos_.endpoint().history_memory_policy);
pool_config_ = PoolConfig::from_history_attributes(history_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 == pool_config_.memory_policy &&
(type_->is_bounded() || type_->is_plain(data_representation_)))
{
pool_config_.memory_policy = PREALLOCATED_MEMORY_MODE;
}

WriterAttributes w_att;
w_att.endpoint.durabilityKind = qos_.durability().durabilityKind();
w_att.endpoint.endpointKind = WRITER;
Expand Down Expand Up @@ -2056,28 +2064,19 @@ std::shared_ptr<IPayloadPool> DataWriterImpl::get_payload_pool()
{
if (!payload_pool_)
{
PoolConfig config = pool_config_;

// 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 &&
(type_->is_bounded() || type_->is_plain(data_representation_)))
{
config.memory_policy = PREALLOCATED_MEMORY_MODE;
}

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

// Get payload pool reference and allocate space for our history
if (is_data_sharing_compatible_)
{
payload_pool_ = DataSharingPayloadPool::get_writer_pool(config);
payload_pool_ = DataSharingPayloadPool::get_writer_pool(pool_config_);
}
else
{
payload_pool_ = TopicPayloadPoolRegistry::get(topic_->get_name(), config);
if (!std::static_pointer_cast<ITopicPayloadPool>(payload_pool_)->reserve_history(config, false))
payload_pool_ = TopicPayloadPoolRegistry::get(topic_->get_name(), pool_config_);
if (!std::static_pointer_cast<ITopicPayloadPool>(payload_pool_)->reserve_history(pool_config_, false))
{
payload_pool_.reset();
}
Expand All @@ -2086,7 +2085,7 @@ std::shared_ptr<IPayloadPool> DataWriterImpl::get_payload_pool()
// Prepare loans collection for plain types only
if (type_->is_plain(data_representation_))
{
loans_.reset(new LoanCollection(config));
loans_.reset(new LoanCollection(pool_config_));
}
}

Expand Down
Loading