Always add invalid sample if empty or latest read

Disposing an instance would only add an invalid sample if the instance
is empty, but it should also do so when the latest sample is read.
Otherwise reading all NOT_READ samples gives nothing or nonsensical
output.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-04-29 20:00:51 +02:00 committed by eboasson
parent 0be287b67b
commit 6800887a74
2 changed files with 2 additions and 2 deletions

View file

@ -1648,7 +1648,7 @@ static bool dds_rhc_default_store (struct ddsi_rhc * __restrict rhc_common, cons
}
/* If instance became disposed, add an invalid sample if there are no samples left */
if (inst_became_disposed && inst->latest == NULL)
if (inst_became_disposed && (inst->latest == NULL || inst->latest->isread))
inst_set_invsample (rhc, inst, &trig_qc, &notify_data_available);
update_inst (inst, wrinfo, true, sample->timestamp);

View file

@ -55,7 +55,7 @@
#define MAX_SAMPLES 21
#define RDR_NOT_READ_CNT 11
#define RDR_INV_READ_CNT 1
#define RDR_INV_READ_CNT 2
int rdr_expected_long_2[RDR_NOT_READ_CNT] = { 0, 1, 2, 6, 7, 9, 11, 13, 14, 16, 19 };
/* Because we only read one sample at a time, only the first sample of an instance