From 6800887a7433796e1731c86a94d15731b90145d7 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Wed, 29 Apr 2020 20:00:51 +0200 Subject: [PATCH] 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 --- src/core/ddsc/src/dds_rhc_default.c | 2 +- src/core/ddsc/tests/reader_iterator.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ddsc/src/dds_rhc_default.c b/src/core/ddsc/src/dds_rhc_default.c index 09989e0..0a373e7 100644 --- a/src/core/ddsc/src/dds_rhc_default.c +++ b/src/core/ddsc/src/dds_rhc_default.c @@ -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, ¬ify_data_available); update_inst (inst, wrinfo, true, sample->timestamp); diff --git a/src/core/ddsc/tests/reader_iterator.c b/src/core/ddsc/tests/reader_iterator.c index df1e4c1..945564c 100644 --- a/src/core/ddsc/tests/reader_iterator.c +++ b/src/core/ddsc/tests/reader_iterator.c @@ -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