Skip to content

Commit

Permalink
Rely on via_psmx flag in deliver_locally_slowpath
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eboasson committed Sep 6, 2023
1 parent 7ece102 commit b7651fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
23 changes: 0 additions & 23 deletions src/core/ddsi/src/ddsi_deliver_locally.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions src/core/ddsi/src/ddsi_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions src/core/ddsi/src/ddsi_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit b7651fd

Please sign in to comment.