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