Skip to content

Commit

Permalink
WiP: repeat requests for types until deps resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
eboasson committed Sep 6, 2024
1 parent 4c510fd commit bcae182
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/core/ddsi/src/ddsi_typelib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,14 +1539,30 @@ static dds_return_t check_type_resolved_impl_locked (struct ddsi_domaingv *gv, c
return ret;
}

static dds_return_t wait_for_type_resolved_impl_locked (struct ddsi_domaingv *gv, dds_duration_t timeout, const struct ddsi_type *type, enum ddsi_type_include_deps resolved_kind)
static dds_return_t wait_for_type_resolved_impl_locked (struct ddsi_domaingv *gv, const ddsi_typeid_t *type_id, dds_duration_t timeout, const struct ddsi_type *type, enum ddsi_type_include_deps resolved_kind, ddsi_type_request_t request)
{
#ifndef DDS_HAS_TYPE_DISCOVERY
(void)type_id;
(void)request;
#endif
const dds_time_t tnow = dds_time ();
const dds_time_t abstimeout = (DDS_INFINITY - timeout <= tnow) ? DDS_NEVER : (tnow + timeout);
while (!ddsi_type_resolved_locked (gv, type, resolved_kind))
bool resolved = ddsi_type_resolved_locked (gv, type, resolved_kind);
while (!resolved)
{
if (!ddsrt_cond_waituntil (&gv->typelib_resolved_cond, &gv->typelib_lock, abstimeout))
return DDS_RETCODE_TIMEOUT;
resolved = ddsi_type_resolved_locked (gv, type, resolved_kind);
#ifdef DDS_HAS_TYPE_DISCOVERY
if (request == DDSI_TYPE_SEND_REQUEST && !resolved)
{
ddsrt_mutex_unlock (&gv->typelib_lock);
if (!ddsi_tl_request_type (gv, type_id, NULL, resolved_kind))
request = DDSI_TYPE_NO_REQUEST;
ddsrt_mutex_lock (&gv->typelib_lock);
resolved = ddsi_type_resolved_locked (gv, type, resolved_kind);
}
#endif
}
ddsi_type_ref_locked (gv, NULL, type);
return DDS_RETCODE_OK;
Expand Down Expand Up @@ -1578,7 +1594,7 @@ dds_return_t ddsi_wait_for_type_resolved (struct ddsi_domaingv *gv, const ddsi_t
#endif

ddsrt_mutex_lock (&gv->typelib_lock);
ret = wait_for_type_resolved_impl_locked (gv, timeout, *type, resolved_kind);
ret = wait_for_type_resolved_impl_locked (gv, type_id, timeout, *type, resolved_kind, request);
ddsrt_mutex_unlock (&gv->typelib_lock);

return ret;
Expand Down

0 comments on commit bcae182

Please sign in to comment.