Commit a46bbeaa authored by Kishen Maloor's avatar Kishen Maloor

observe: remove observers following a hard RESET

Change-Id: I62451165aad2c6c9feb2cecd9362a87efec1f46e
Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent e046e45b
......@@ -474,14 +474,15 @@ coap_notify_collections(oc_resource_t *resource)
#ifdef OC_SECURITY
int
coap_remove_observers_on_dos_change(size_t device)
coap_remove_observers_on_dos_change(size_t device, bool reset)
{
/* iterate over observers */
coap_observer_t *obs = (coap_observer_t *)oc_list_head(observers_list);
while (obs != NULL) {
if (obs->endpoint.device == device &&
(reset ||
!oc_sec_check_acl(OC_GET, obs->resource,
obs->resource->default_interface, &obs->endpoint)) {
obs->resource->default_interface, &obs->endpoint))) {
coap_observer_t *o = obs;
coap_packet_t notification[1];
#ifdef OC_TCP
......
......@@ -106,7 +106,7 @@ int coap_observe_handler(void *request, void *response, oc_resource_t *resource,
oc_interface_mask_t iface_mask);
#endif /* !OC_BLOCK_WISE */
int coap_remove_observers_on_dos_change(size_t device);
int coap_remove_observers_on_dos_change(size_t device, bool reset);
#ifdef __cplusplus
}
......
......@@ -168,10 +168,10 @@ oc_pstat_handle_state(oc_sec_pstat_t *ps, size_t device, bool from_storage,
#endif /* OC_SERVER */
store_unique_ids = true;
#ifdef OC_SERVER
coap_remove_observers_on_dos_change(device);
#if defined(OC_COLLECTIONS) && defined(OC_COLLECTIONS_IF_CREATE)
oc_rt_factory_free_created_resources(device);
#endif /* OC_COLLECTIONS && OC_COLLECTIONS_IF_CREATE */
coap_remove_observers_on_dos_change(device, true);
#endif /* OC_SERVER */
ps->p = false;
}
......@@ -261,7 +261,7 @@ oc_pstat_handle_state(oc_sec_pstat_t *ps, size_t device, bool from_storage,
} break;
case OC_DOS_RFNOP: {
#ifdef OC_SERVER
coap_remove_observers_on_dos_change(device);
coap_remove_observers_on_dos_change(device, false);
#endif /* OC_SERVER */
ps->p = true;
ps->cm = 0;
......
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