Skip to content

Commit

Permalink
Remove change before creation in full writer's history (#122)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
  • Loading branch information
juanlofer-eprosima authored Jun 19, 2024
1 parent e97bdc1 commit 37364bc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ utils::ReturnCode CommonWriter::write_nts_(
{
auto& rtps_data = dynamic_cast<RtpsPayloadData&>(data);

if (rtps_history_->isFull())
{
// Remove the oldest cache change when the max history size is reached.
// NOTE: This should be done as a first step, otherwise the creation of a new change would fail.
rtps_history_->remove_min_change();
}

// Take new Change from history
fastrtps::rtps::CacheChange_t* new_change;

Expand Down Expand Up @@ -191,12 +198,6 @@ utils::ReturnCode CommonWriter::write_nts_(
return ret;
}

if (rtps_history_->isFull())
{
// Remove the oldest cache change when the max history size is reached.
rtps_history_->remove_min_change();
}

// Send data by adding it to CommonWriter History
rtps_history_->add_change(new_change, write_params);

Expand Down

0 comments on commit 37364bc

Please sign in to comment.