Commit fa16da1e authored by Kishen Maloor's avatar Kishen Maloor

Fix race while deleting links from Collections

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent bdb0410e
......@@ -122,7 +122,8 @@ oc_delete_link(oc_link_t *link)
oc_memb_free(&oc_params_s, p);
p = (oc_link_params_t *)oc_list_pop(link->params);
}
if (link->resource) {
if (oc_ri_is_app_resource_valid(link->resource) ||
oc_check_if_collection(link->resource)) {
link->resource->num_links--;
}
oc_free_string_array(&(link->rel));
......
......@@ -142,6 +142,19 @@ oc_ri_get_app_resources(void)
{
return oc_list_head(app_resources);
}
bool
oc_ri_is_app_resource_valid(oc_resource_t *resource)
{
oc_resource_t *res = oc_ri_get_app_resources();
while (res) {
if (res == resource) {
return true;
}
res = res->next;
}
return false;
}
#endif
int
......
......@@ -269,6 +269,8 @@ int oc_ri_get_query_value(const char *query, size_t query_len, const char *key,
oc_interface_mask_t oc_ri_get_interface_mask(char *iface, size_t if_len);
bool oc_ri_is_app_resource_valid(oc_resource_t *resource);
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment