Skip to content

Commit

Permalink
fixup! gcoap_dtls: destroy session in _tl_send only on connection errors
Browse files Browse the repository at this point in the history
(cherry picked from commit a8cf45f)
Signed-off-by: Martine Lenders <[email protected]>

From PR16963
  • Loading branch information
miri64 committed Oct 8, 2021
1 parent 7893db0 commit a14dea1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,17 @@ static ssize_t _tl_send(gcoap_socket_t *sock, const void *data, size_t len,
res = sock_dtls_send(sock->socket.dtls, &sock->ctx_dtls_session, data, len,
SOCK_NO_TIMEOUT);
switch (res) {
case -EHOSTUNREACH:
case -ENOTCONN:
case 0:
dsm_remove(sock->socket.dtls, &sock->ctx_dtls_session);
sock_dtls_session_destroy(sock->socket.dtls, &sock->ctx_dtls_session);
break;
default:
break;
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) {
Expand Down

0 comments on commit a14dea1

Please sign in to comment.