Skip to content

Commit

Permalink
Server Keepalive: Timeout sessions observing Unknown or Proxy resources
Browse files Browse the repository at this point in the history
In general, the Unknown or Proxy resources should not be set as observable.
  • Loading branch information
mrdeep1 committed Feb 17, 2025
1 parent 1827407 commit a51fa3b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/coap_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,18 +604,32 @@ coap_session_free(coap_session_t *session) {
#if COAP_SERVER_SUPPORT
void
coap_session_server_keepalive_failed(coap_session_t *session) {
int i;

coap_session_reference_lkd(session);
coap_handle_event_lkd(session->context, COAP_EVENT_KEEPALIVE_FAILURE, session);
coap_cancel_all_messages(session->context, session, NULL);
RESOURCES_ITER(session->context->resources, r) {
int i;

/* In case code is broken somewhere */
for (i = 0; i < 1000; i++) {
if (!coap_delete_observer(r, session, NULL))
break;
}
}
if (session->context->unknown_resource) {
/* In case code is broken somewhere */
for (i = 0; i < 1000; i++) {
if (!coap_delete_observer(session->context->unknown_resource, session, NULL))
break;
}
}
if (session->context->proxy_uri_resource) {
/* In case code is broken somewhere */
for (i = 0; i < 1000; i++) {
if (!coap_delete_observer(session->context->proxy_uri_resource, session, NULL))
break;
}
}
while (session->delayqueue) {
coap_queue_t *q = session->delayqueue;

Expand Down

0 comments on commit a51fa3b

Please sign in to comment.