Skip to content
Open
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
14 changes: 7 additions & 7 deletions src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ DataReaderHistory::DataReaderHistory(
compute_key_for_change_fn_ = [](CacheChange_t* change)
{
change->instanceHandle = c_InstanceHandle_Unknown;
return true;
return change->is_fully_assembled();
};
}
else
Expand Down Expand Up @@ -728,7 +728,7 @@ ReaderHistory::iterator DataReaderHistory::remove_change_nts(

if (ret_val == changesEnd() || !matches_change(&dummy_change, *ret_val)) // Change was successfully removed.
{
if (!has_keys_ || is_fully_assembled)
if (is_fully_assembled)
{
// clean any references to this CacheChange in the key state collection
auto it = instances_.find(dummy_change.instanceHandle);
Expand Down Expand Up @@ -786,8 +786,7 @@ bool DataReaderHistory::completed_change(
InstanceCollection::iterator vit;
if (find_key(change->instanceHandle, vit))
{
ret_value = !change->instanceHandle.isDefined() ||
complete_fn_(change, *vit->second, unknown_missing_changes_up_to, rejection_reason);
ret_value = complete_fn_(change, *vit->second, unknown_missing_changes_up_to, rejection_reason);
}
}

Expand Down Expand Up @@ -826,7 +825,7 @@ bool DataReaderHistory::completed_change_keep_last(
CacheChange_t* change,
DataReaderInstance& instance,
size_t,
SampleRejectedStatusKind&)
SampleRejectedStatusKind& rejection_reason)
{
bool ret_value = false;
DataReaderInstance::ChangeCollection& instance_changes = instance.cache_changes;
Expand All @@ -845,8 +844,9 @@ bool DataReaderHistory::completed_change_keep_last(
}
else
{
// Received change is older than oldest, and should be discarded
return true;
// Completed change is older than oldest, and should be discarded
rejection_reason = NOT_REJECTED;
return false;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/cpp/fastdds/subscriber/history/DataReaderHistory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ class DataReaderHistory : public eprosima::fastdds::rtps::ReaderHistory
* @param [in] unknown_missing_changes_up_to Number of missing changes before this one
* @param [out] rejection_reason In case of been rejected the sample, it will contain the reason of the rejection.
*
* @return Whether the operation succeeded.
* @return Whether the operation succeeded. When it did not and @c rejection_reason is NOT_REJECTED, the change
* was discarded because it is older than the samples kept in its instance.
*/
bool completed_change(
CacheChange_t* change,
Expand Down
13 changes: 12 additions & 1 deletion src/cpp/rtps/reader/StatefulReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,10 @@ bool StatefulReader::process_data_frag_msg(
if (work_change != nullptr && work_change->is_fully_assembled())
{
fastdds::dds::SampleRejectedStatusKind rejection_reason;
if (history_->completed_change(work_change, changes_up_to, rejection_reason))
// A change created complete, because its first DATA_FRAG carried every fragment, was already added
// to its instance by change_received.
if (change_created != nullptr ||
history_->completed_change(work_change, changes_up_to, rejection_reason))
{
pWP->received_change_set(work_change->sequenceNumber);

Expand Down Expand Up @@ -867,6 +870,14 @@ bool StatefulReader::process_data_frag_msg(
has_to_notify = true;
}
}
else
{
/* Not rejected but discarded, as it is older than the samples a KEEP_LAST instance keeps.
* It should never be received again.
*/
pWP->irrelevant_change_set(work_change->sequenceNumber);
has_to_notify = true;
}

History::const_iterator chit = history_->find_change_nts(work_change);
if (chit != history_->changesEnd())
Expand Down
Loading
Loading