coap_session.c: Clean up session close down order

This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2025-07-07 17:55:46 +01:00
1 parent 6d322e1f1c
commit 33b3f02006
2 files changed
+13 -9

No files matched your search

+4
View File
@@ -392,6 +392,10 @@ typedef enum {
} coap_event_t;
----
*NOTE:* For the COAP_*_CLOSED events, as these are triggered when a session is
closing down, not all the information may be there in the _session_ parameter
passed to the application event handler.
EXAMPLES
--------
*GET Resource Callback Handler*
+9 -9
View File
@@ -551,6 +551,15 @@ coap_session_mfree(coap_session_t *session) {
}
#endif /* COAP_CLIENT_SUPPORT */
LL_FOREACH_SAFE(session->delayqueue, q, tmp) {
if (q->pdu->type==COAP_MESSAGE_CON) {
coap_handle_nack(session, q->pdu,
session->proto == COAP_PROTO_DTLS ?
COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE,
q->id);
}
coap_delete_node_lkd(q);
}
if (session->partial_pdu)
coap_delete_pdu_lkd(session->partial_pdu);
if (session->sock.lfunc[COAP_LAYER_SESSION].l_close)
@@ -571,15 +580,6 @@ coap_session_mfree(coap_session_t *session) {
}
}
#endif /* COAP_PROXY_SUPPORT */
LL_FOREACH_SAFE(session->delayqueue, q, tmp) {
if (q->pdu->type==COAP_MESSAGE_CON) {
coap_handle_nack(session, q->pdu,
session->proto == COAP_PROTO_DTLS ?
COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE,
q->id);
}
coap_delete_node_lkd(q);
}
LL_FOREACH_SAFE(session->lg_xmit, lq, ltmp) {
LL_DELETE(session->lg_xmit, lq);
coap_block_delete_lg_xmit(session, lq);