From b7651fdeae298c4d90febecfa7671ca98a9f463a Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Wed, 6 Sep 2023 10:13:48 +0200 Subject: [PATCH] Rely on via_psmx flag in deliver_locally_slowpath Note that this requires the first/next reader operations passed in to check the flag and skip readers that have it set, but that is perfectly reasonable. Signed-off-by: Erik Boasson --- src/core/ddsi/src/ddsi_deliver_locally.c | 23 ----------------------- src/core/ddsi/src/ddsi_endpoint.c | 4 ++++ src/core/ddsi/src/ddsi_receive.c | 4 ++-- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/core/ddsi/src/ddsi_deliver_locally.c b/src/core/ddsi/src/ddsi_deliver_locally.c index 555fa2c401..24623870f5 100644 --- a/src/core/ddsi/src/ddsi_deliver_locally.c +++ b/src/core/ddsi/src/ddsi_deliver_locally.c @@ -165,25 +165,6 @@ dds_return_t ddsi_deliver_locally_one (struct ddsi_domaingv *gv, struct ddsi_ent return DDS_RETCODE_OK; } -static bool is_psmx_source_entity (const struct ddsi_entity_common *entity) -{ - // FIXME: ok only if #psmx <= 1 - switch (entity->kind) - { - case DDSI_EK_WRITER: { - struct ddsi_writer const * const wr = (struct ddsi_writer *) entity; - return wr->c.psmx_locators.length > 0; - } - case DDSI_EK_PROXY_WRITER: { - struct ddsi_proxy_writer const * const pwr = (struct ddsi_proxy_writer *) entity; - return pwr->local_psmx; - } - default: { - return false; - } - } -} - static dds_return_t deliver_locally_slowpath (struct ddsi_domaingv *gv, struct ddsi_entity_common *source_entity, bool source_entity_locked, const struct ddsi_writer_info *wrinfo, const struct ddsi_deliver_locally_ops * __restrict ops, void *vsourceinfo) { /* When deleting, pwr is no longer accessible via the hash @@ -201,15 +182,11 @@ static dds_return_t deliver_locally_slowpath (struct ddsi_domaingv *gv, struct d ddsrt_mutex_lock (&source_entity->lock); /* Local delivery from a PSMX writer to a PSMX reader is handled by PSMX and we must skip them here */ - const bool skip_psmx = is_psmx_source_entity (source_entity); bool trace_is_first = true; for (struct ddsi_reader *rd = ops->first_reader (gv->entity_index, source_entity, &it); rd != NULL; rd = ops->next_reader (gv->entity_index, &it)) { - // FIXME: ok only if #psmx <= 1 - if (skip_psmx && rd->c.psmx_locators.length > 0) - continue; struct ddsi_serdata *payload; struct ddsi_tkmap_instance *tk; if (!type_sample_cache_lookup (&payload, &tk, &tsc, rd->type)) diff --git a/src/core/ddsi/src/ddsi_endpoint.c b/src/core/ddsi/src/ddsi_endpoint.c index afa4ac8bf4..40d492ac29 100644 --- a/src/core/ddsi/src/ddsi_endpoint.c +++ b/src/core/ddsi/src/ddsi_endpoint.c @@ -1626,11 +1626,15 @@ struct ddsi_reader *ddsi_writer_first_in_sync_reader (struct ddsi_entity_index * assert (wrcmn->kind == DDSI_EK_WRITER); struct ddsi_writer *wr = (struct ddsi_writer *) wrcmn; struct ddsi_wr_rd_match *m = ddsrt_avl_iter_first (&ddsi_wr_local_readers_treedef, &wr->local_readers, it); + while (m && m->via_psmx) + m = ddsrt_avl_iter_next (it); return m ? ddsi_entidx_lookup_reader_guid (entity_index, &m->rd_guid) : NULL; } struct ddsi_reader *ddsi_writer_next_in_sync_reader (struct ddsi_entity_index *entity_index, ddsrt_avl_iter_t *it) { struct ddsi_wr_rd_match *m = ddsrt_avl_iter_next (it); + while (m && m->via_psmx) + m = ddsrt_avl_iter_next (it); return m ? ddsi_entidx_lookup_reader_guid (entity_index, &m->rd_guid) : NULL; } diff --git a/src/core/ddsi/src/ddsi_receive.c b/src/core/ddsi/src/ddsi_receive.c index 947094e2b5..9429ce0730 100644 --- a/src/core/ddsi/src/ddsi_receive.c +++ b/src/core/ddsi/src/ddsi_receive.c @@ -2131,7 +2131,7 @@ static struct ddsi_reader *proxy_writer_first_in_sync_reader (struct ddsi_entity struct ddsi_pwr_rd_match *m; struct ddsi_reader *rd; for (m = ddsrt_avl_iter_first (&ddsi_pwr_readers_treedef, &pwr->readers, it); m != NULL; m = ddsrt_avl_iter_next (it)) - if (m->in_sync == PRMSS_SYNC && (rd = ddsi_entidx_lookup_reader_guid (entity_index, &m->rd_guid)) != NULL) + if (!m->via_psmx && m->in_sync == PRMSS_SYNC && (rd = ddsi_entidx_lookup_reader_guid (entity_index, &m->rd_guid)) != NULL) return rd; return NULL; } @@ -2141,7 +2141,7 @@ static struct ddsi_reader *proxy_writer_next_in_sync_reader (struct ddsi_entity_ struct ddsi_pwr_rd_match *m; struct ddsi_reader *rd; for (m = ddsrt_avl_iter_next (it); m != NULL; m = ddsrt_avl_iter_next (it)) - if (m->in_sync == PRMSS_SYNC && (rd = ddsi_entidx_lookup_reader_guid (entity_index, &m->rd_guid)) != NULL) + if (!m->via_psmx && m->in_sync == PRMSS_SYNC && (rd = ddsi_entidx_lookup_reader_guid (entity_index, &m->rd_guid)) != NULL) return rd; return NULL; }