mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
Merge pull request #16963 from miri64/gcoap_dtls/fix/session-destroy-only-on-conn-errors
gcoap_dtls: destroy session in _tl_send only on connection errors
This commit is contained in:
commit
94c852cfa7
@ -910,9 +910,18 @@ static ssize_t _tl_send(gcoap_socket_t *sock, const void *data, size_t len,
|
||||
/* send application data */
|
||||
res = sock_dtls_send(sock->socket.dtls, &sock->ctx_dtls_session, data, len,
|
||||
SOCK_NO_TIMEOUT);
|
||||
if (res <= 0 ) {
|
||||
switch (res) {
|
||||
case -EHOSTUNREACH:
|
||||
case -ENOTCONN:
|
||||
case 0:
|
||||
DEBUG("gcoap: DTLS sock not connected or remote unreachable. "
|
||||
"Destroying session.\n");
|
||||
dsm_remove(sock->socket.dtls, &sock->ctx_dtls_session);
|
||||
sock_dtls_session_destroy(sock->socket.dtls, &sock->ctx_dtls_session);
|
||||
break;
|
||||
default:
|
||||
/* Temporary error. Keeping the DTLS session */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} else if (sock->type == GCOAP_SOCKET_TYPE_UDP) {
|
||||
|
Loading…
Reference in New Issue
Block a user