mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-25 00:21:09 +03:00
Merge pull request #432 from mrdeep1/endpoint_closure_message
coap_session.c: Re-order socket closure so TLS closed messages are sent
This commit is contained in:
1 file changed
+16
-3
+16
-3
@@ -1089,15 +1089,28 @@ coap_free_endpoint(coap_endpoint_t *ep) {
|
||||
if (ep) {
|
||||
coap_session_t *session, *rtmp;
|
||||
|
||||
if (ep->sock.flags != COAP_SOCKET_EMPTY)
|
||||
coap_socket_close(&ep->sock);
|
||||
|
||||
SESSIONS_ITER_SAFE(ep->sessions, session, rtmp) {
|
||||
assert(session->ref == 0);
|
||||
if (session->ref == 0) {
|
||||
coap_session_free(session);
|
||||
}
|
||||
}
|
||||
if (ep->sock.flags != COAP_SOCKET_EMPTY) {
|
||||
/*
|
||||
* ep->sock.endpoint is set in coap_new_endpoint().
|
||||
* ep->sock.session is never set.
|
||||
*
|
||||
* session->sock.session is set for both clients and servers (when a
|
||||
* new session is accepted), but does not affect the endpoint.
|
||||
*
|
||||
* So, it is safe to call coap_socket_close() after all the sessions
|
||||
* have been freed above as we are only working with the endpoint sock.
|
||||
*/
|
||||
#ifdef COAP_EPOLL_SUPPORT
|
||||
assert(ep->sock.session == NULL);
|
||||
#endif /* COAP_EPOLL_SUPPORT */
|
||||
coap_socket_close(&ep->sock);
|
||||
}
|
||||
|
||||
if (ep->context) {
|
||||
LL_DELETE(ep->context->endpoint, ep);
|
||||
|
||||
Reference in new issue
Block a user