Skip to content

Commit 256f539

Browse files
committed
Use lifespan set to DDSRT_MTIME_NEVER when adding historical serdata to the rhc of a durable reader
Signed-off-by: TheFixer <[email protected]>
1 parent 4488be1 commit 256f539

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/core/ddsc/src/dds_reader.c

+19-10
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ dds_return_t dds_reader_store_historical_serdata (dds_entity_t reader, dds_guid_
565565
dds_reader *dds_rd = (dds_reader *) e;
566566
struct ddsi_reader *rd = dds_rd->m_rd;
567567
struct ddsi_domaingv *gv = rd->e.gv;
568-
569568
/* The serdata->writer_info contains the ddsi guid in BE format.
570569
* To compare this with the guid we'll transfer the guid
571570
* to the right format and compare both.
@@ -575,19 +574,24 @@ dds_return_t dds_reader_store_historical_serdata (dds_entity_t reader, dds_guid_
575574
struct ddsi_guid ddsiguid, tmp;
576575
memcpy(&tmp, &guid, 16);
577576
ddsiguid = ddsi_ntoh_guid(tmp);
578-
579577
ddsi_thread_state_awake (ddsi_lookup_thread_state (), gv);
580578
ddsrt_mutex_lock (&rd->e.lock);
581-
582579
/* retrieve the topic key map used to get the instance id of the serdata */
583-
struct ddsi_tkmap_instance * tk = ddsi_tkmap_lookup_instance_ref (gv->m_tkmap, serdata);
580+
struct ddsi_tkmap_instance *tk = ddsi_tkmap_lookup_instance_ref (gv->m_tkmap, serdata);
584581
if (tk == NULL) {
585582
ret = DDS_RETCODE_BAD_PARAMETER;
586-
goto fail_get_writer_info;
583+
goto fail_tkmap_lookup;
584+
}
585+
/* retrieve the builtin key map to get the iid for the writer */
586+
struct ddsi_tkmap_instance *tk_builtin = ddsi_builtintopic_get_tkmap_entry(gv->builtin_topic_interface, &ddsiguid);
587+
if (tk_builtin == NULL) {
588+
ret = DDS_RETCODE_BAD_PARAMETER;
589+
goto fail_tk_builtin;
587590
}
588-
589591
/* historical data is always unregistered */
590-
serdata->statusinfo |= DDSI_STATUSINFO_UNREGISTER;
592+
if (!ddsi_builtintopic_is_visible(gv->builtin_topic_interface, &ddsiguid, ddsi_get_entity_vendorid(&rd->e))) {
593+
serdata->statusinfo |= DDSI_STATUSINFO_UNREGISTER;
594+
}
591595
/* set the writer guid of the serdata */
592596
serdata->writer_guid = ddsiguid;
593597
/* timestamp and seqnum have already been set in the serdata by the caller */
@@ -599,18 +603,23 @@ dds_return_t dds_reader_store_historical_serdata (dds_entity_t reader, dds_guid_
599603
*/
600604
struct ddsi_writer_info wi;
601605
wi.guid = ddsiguid;
602-
wi.ownership_strength = INT32_MIN; /* use the lowest possible strength to ensure that live writers with a */
606+
wi.ownership_strength = INT32_MIN; /* use the lowest possible strength to ensure that live writers always take precedence */
603607
wi.auto_dispose = autodispose;
604-
wi.iid = tk->m_iid;
608+
wi.iid = tk_builtin->m_iid;
609+
#ifdef DDS_HAS_LIFESPAN
610+
wi.lifespan_exp = DDSRT_MTIME_NEVER;
611+
#endif
605612
if (!dds_rhc_store (dds_rd->m_rhc, &wi, serdata, tk))
606613
{
607614
ret = DDS_RETCODE_ERROR;
608615
goto fail_rhc_store;
609616
}
610617

611618
fail_rhc_store:
619+
ddsi_tkmap_instance_unref (gv->m_tkmap, tk_builtin);
620+
fail_tk_builtin:
612621
ddsi_tkmap_instance_unref (gv->m_tkmap, tk);
613-
fail_get_writer_info:
622+
fail_tkmap_lookup:
614623
ddsrt_mutex_unlock (&rd->e.lock);
615624
ddsi_thread_state_asleep (ddsi_lookup_thread_state ());
616625
dds_entity_unpin (e);

0 commit comments

Comments
 (0)