Fix a race condition in delete_participant, that could occur on security permissions or identity expiry, which triggers a delete of the local participant

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
This commit is contained in:
Dennis Potman 2020-05-15 14:10:11 +02:00 committed by eboasson
parent a151c5f184
commit 2e6ea36fda
2 changed files with 6 additions and 1 deletions

View file

@ -842,7 +842,7 @@ static bool delete_pp_by_handle (DDS_Security_Handle handle, expired_pp_check_fn
{
if (q_omg_participant_is_secure (pp) && expired_pp_check_fn (pp, handle))
{
delete_participant (gv, &pp->e.guid);
(void) delete_participant (gv, &pp->e.guid);
result = true;
}
}

View file

@ -1308,14 +1308,19 @@ dds_return_t delete_participant (struct ddsi_domaingv *gv, const struct ddsi_gui
{
struct participant *pp;
GVLOGDISC ("delete_participant("PGUIDFMT")\n", PGUID (*ppguid));
ddsrt_mutex_lock (&gv->lock);
if ((pp = entidx_lookup_participant_guid (gv->entity_index, ppguid)) == NULL)
{
ddsrt_mutex_unlock (&gv->lock);
return DDS_RETCODE_BAD_PARAMETER;
}
builtintopic_write (gv->builtin_topic_interface, &pp->e, ddsrt_time_wallclock(), false);
remember_deleted_participant_guid (gv->deleted_participants, &pp->e.guid);
#ifdef DDSI_INCLUDE_SECURITY
disconnect_participant_secure (pp);
#endif
entidx_remove_participant_guid (gv->entity_index, pp);
ddsrt_mutex_unlock (&gv->lock);
gcreq_participant (pp);
return 0;
}