@@ -565,7 +565,6 @@ dds_return_t dds_reader_store_historical_serdata (dds_entity_t reader, dds_guid_
565
565
dds_reader * dds_rd = (dds_reader * ) e ;
566
566
struct ddsi_reader * rd = dds_rd -> m_rd ;
567
567
struct ddsi_domaingv * gv = rd -> e .gv ;
568
-
569
568
/* The serdata->writer_info contains the ddsi guid in BE format.
570
569
* To compare this with the guid we'll transfer the guid
571
570
* 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_
575
574
struct ddsi_guid ddsiguid , tmp ;
576
575
memcpy (& tmp , & guid , 16 );
577
576
ddsiguid = ddsi_ntoh_guid (tmp );
578
-
579
577
ddsi_thread_state_awake (ddsi_lookup_thread_state (), gv );
580
578
ddsrt_mutex_lock (& rd -> e .lock );
581
-
582
579
/* 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 );
584
581
if (tk == NULL ) {
585
582
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 ;
587
590
}
588
-
589
591
/* 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
+ }
591
595
/* set the writer guid of the serdata */
592
596
serdata -> writer_guid = ddsiguid ;
593
597
/* 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_
599
603
*/
600
604
struct ddsi_writer_info wi ;
601
605
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 */
603
607
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
605
612
if (!dds_rhc_store (dds_rd -> m_rhc , & wi , serdata , tk ))
606
613
{
607
614
ret = DDS_RETCODE_ERROR ;
608
615
goto fail_rhc_store ;
609
616
}
610
617
611
618
fail_rhc_store :
619
+ ddsi_tkmap_instance_unref (gv -> m_tkmap , tk_builtin );
620
+ fail_tk_builtin :
612
621
ddsi_tkmap_instance_unref (gv -> m_tkmap , tk );
613
- fail_get_writer_info :
622
+ fail_tkmap_lookup :
614
623
ddsrt_mutex_unlock (& rd -> e .lock );
615
624
ddsi_thread_state_asleep (ddsi_lookup_thread_state ());
616
625
dds_entity_unpin (e );
0 commit comments