From f3d3aca527ce7fa396ed8de4140d5fa6589a654c Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Wed, 1 Aug 2018 12:22:53 +0100 Subject: [PATCH] src/resource.c: Non Confirmable observe requests not gettng out if CON pending If an non-confirmable observe response was triggered, and there was already a CON message outstanding, then the observe response would not get sent in error. [Example being a observe response following a Ping 0.00 that has not yet had a reply] The fix is to check whether the observe request is non-confirmable and there are less than COAP_OBS_MAX_NON already sent to allow it to get sent. --- src/resource.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/resource.c b/src/resource.c index 59add5ac..7330a5fd 100644 --- a/src/resource.c +++ b/src/resource.c @@ -742,9 +742,14 @@ coap_notify_observers(coap_context_t *context, coap_resource_t *r) { LL_FOREACH(r->subscribers, obs) { if (r->dirty == 0 && obs->dirty == 0) - /* running this resource due to partiallydirty, but this observation's notification was already enqueued */ + /* + * running this resource due to partiallydirty, but this observation's + * notification was already enqueued + */ continue; - if (obs->session->con_active >= COAP_DEFAULT_NSTART) + if (obs->session->con_active >= COAP_DEFAULT_NSTART && + ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) || + (obs->non_cnt >= COAP_OBS_MAX_NON))) continue; coap_tid_t tid = COAP_INVALID_TID;