In the latest version of the OMG DCPS specification(DDS V1.4), the content of the DATA_AVAILABLE state mentioned in section 2.2.4.1 is that the new information is valid.
Why in the implementation of cyclonedds, the callback is triggered when the writer cancels the match? According to my opinion that when the writer cancels the match, it should involve the state change of SUBSCRIPTION_MATCHED, which triggers on_subscription_matched.
In fact, the callback on_data_available is triggered in dds_rhc_default_unregister_wr in dds_rhc_default.c.
static void dds_rhc_default_unregister_wr (struct ddsi_rhc * __restrict rhc_common, const struct ddsi_writer_info * __restrict wrinfo)
{
/* Only to be called when writer with ID WR_IID has died.
If we require that it will NEVER be resurrected, i.e., that next
time a new WR_IID will be used for the same writer, then we have
all the time in the world to scan the cache & clean up and that
we don't have to keep it locked all the time (even if we do it
that way now).
WR_IID was never reused while the built-in topics weren't getting
generated, but those really require the same instance id for the
same GUID if an instance still exists in some reader for that GUID.
So, if unregistration without locking the RHC is desired, entities
need to get two IIDs: the one visible to the application in the
built-in topics and in get_instance_handle, and one used internally
for tracking registrations and unregistrations. */
struct dds_rhc_default * __restrict const rhc = (struct dds_rhc_default * __restrict) rhc_common;
bool notify_data_available = false;
struct rhc_instance *inst;
struct ddsrt_hh_iter iter;
const uint64_t wr_iid = wrinfo->iid;
ddsrt_mutex_lock (&rhc->lock);
TRACE ("rhc_unregister_wr_iid %"PRIx64",%d:\n", wr_iid, wrinfo->auto_dispose);
for (inst = ddsrt_hh_iter_first (rhc->instances, &iter); inst; inst = ddsrt_hh_iter_next (&iter))
{
if ((inst->wr_iid_islive && inst->wr_iid == wr_iid) || lwregs_contains (&rhc->registrations, inst->iid, wr_iid))
{
assert (inst->wrcount > 0);
struct trigger_info_pre pre;
struct trigger_info_post post;
struct trigger_info_qcond trig_qc;
get_trigger_info_pre (&pre, inst);
init_trigger_info_qcond (&trig_qc);
TRACE (" %"PRIx64":", inst->iid);
dds_rhc_unregister (rhc, inst, wrinfo, inst->tstamp, &post, &trig_qc, ¬ify_data_available);
postprocess_instance_update (rhc, &inst, &pre, &post, &trig_qc);
TRACE ("\n");
}
}
ddsrt_mutex_unlock (&rhc->lock);
if (rhc->reader && notify_data_available)
dds_reader_data_available_cb (rhc->reader);
}
According to my understanding, dds_rhc_default_unregister_wr is specifically used for the reader to unregister the peer writer.
Perhaps it would be more appropriate to trigger the on_subscription_matched in the implementation of dds_rhc_default_unregister_wr.
In the latest version of the OMG DCPS specification(DDS V1.4), the content of the DATA_AVAILABLE state mentioned in section 2.2.4.1 is that the new information is valid.
Why in the implementation of cyclonedds, the callback is triggered when the writer cancels the match? According to my opinion that when the writer cancels the match, it should involve the state change of SUBSCRIPTION_MATCHED, which triggers
on_subscription_matched.In fact, the callback
on_data_availableis triggered indds_rhc_default_unregister_wrin dds_rhc_default.c.According to my understanding, dds_rhc_default_unregister_wr is specifically used for the reader to unregister the peer writer.
Perhaps it would be more appropriate to trigger the
on_subscription_matchedin the implementation ofdds_rhc_default_unregister_wr.