eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
847 stars 350 forks source link

Does Data(M) carry unregister dispose information? what is the scenarios? #2082

Open caojiebao opened 2 weeks ago

caojiebao commented 2 weeks ago

The receiver would process unregister-dispose information when processing data(M) messages in function ddsi_handle_pmd_message.

Data(M) will carry unregister dispose information?

void ddsi_handle_pmd_message (const struct ddsi_receiver_state *rst, struct ddsi_serdata *sample_common)
{
  /* use sample with knowledge of internal representation: there's a deserialized sample inside already */
  const struct ddsi_serdata_pserop *sample = (const struct ddsi_serdata_pserop *) sample_common;
  struct ddsi_proxy_participant *proxypp;
  ddsi_guid_t ppguid;
  struct ddsi_lease *l;
  RSTTRACE (" PMD ST%"PRIx32, sample->c.statusinfo);
  switch (sample->c.statusinfo & (DDSI_STATUSINFO_DISPOSE | DDSI_STATUSINFO_UNREGISTER))
  {
    case 0: {
      const ddsi_participant_message_data_t *pmd = sample->sample;
      RSTTRACE (" pp %"PRIx32":%"PRIx32":%"PRIx32" kind %"PRIu32" data %"PRIu32, PGUIDPREFIX (pmd->participantGuidPrefix), pmd->kind, pmd->value.length);
      ppguid.prefix = pmd->participantGuidPrefix;
      ppguid.entityid.u = DDSI_ENTITYID_PARTICIPANT;
      if ((proxypp = ddsi_entidx_lookup_proxy_participant_guid (rst->gv->entity_index, &ppguid)) == NULL)
        RSTTRACE (" PPunknown");
      else if (pmd->kind == DDSI_PARTICIPANT_MESSAGE_DATA_KIND_MANUAL_LIVELINESS_UPDATE &&
               (l = ddsrt_atomic_ldvoidp (&proxypp->minl_man)) != NULL)
      {
        /* Renew lease for entity with shortest manual-by-participant lease */
        ddsi_lease_renew (l, ddsrt_time_elapsed ());
      }
      break;
    }

    case DDSI_STATUSINFO_DISPOSE:
    case DDSI_STATUSINFO_UNREGISTER:
    case DDSI_STATUSINFO_DISPOSE | DDSI_STATUSINFO_UNREGISTER: {
      const ddsi_participant_message_data_t *pmd = sample->sample;
      ppguid.prefix = pmd->participantGuidPrefix;
      ppguid.entityid.u = DDSI_ENTITYID_PARTICIPANT;
      if (ddsi_delete_proxy_participant_by_guid (rst->gv, &ppguid, sample->c.timestamp, 0) < 0)
        RSTTRACE (" unknown");
      else
        RSTTRACE (" delete");
      break;
    }
  }
  RSTTRACE ("\n");
}
caojiebao commented 2 weeks ago

@eboasson