mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-20 20:13:50 +01:00
Merge pull request #20216 from maribu/examples/dtls-sock/error-handling
examples/dtls-sock: fix error handling in client
This commit is contained in:
commit
034fd09e15
@ -155,6 +155,7 @@ static int client_send(char *addr_str, char *data, size_t datalen)
|
|||||||
if (res < 0 && res != CREDMAN_EXIST) {
|
if (res < 0 && res != CREDMAN_EXIST) {
|
||||||
/* ignore duplicate credentials */
|
/* ignore duplicate credentials */
|
||||||
printf("Error cannot add credential to system: %" PRIdSIZE "\n", res);
|
printf("Error cannot add credential to system: %" PRIdSIZE "\n", res);
|
||||||
|
sock_udp_close(&udp_sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,12 +172,14 @@ static int client_send(char *addr_str, char *data, size_t datalen)
|
|||||||
if (res < 0 && res != CREDMAN_EXIST) {
|
if (res < 0 && res != CREDMAN_EXIST) {
|
||||||
/* ignore duplicate credentials */
|
/* ignore duplicate credentials */
|
||||||
printf("Error cannot add credential to system: %" PRIdSIZE "\n", res);
|
printf("Error cannot add credential to system: %" PRIdSIZE "\n", res);
|
||||||
|
sock_udp_close(&udp_sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make the new credential available to the sock */
|
/* make the new credential available to the sock */
|
||||||
if (sock_dtls_add_credential(&dtls_sock, SOCK_DTLS_CLIENT_TAG_1) < 0) {
|
if (sock_dtls_add_credential(&dtls_sock, SOCK_DTLS_CLIENT_TAG_1) < 0) {
|
||||||
printf("Error cannot add credential to the sock: %" PRIdSIZE "\n", res);
|
printf("Error cannot add credential to the sock: %" PRIdSIZE "\n", res);
|
||||||
|
sock_udp_close(&udp_sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +189,7 @@ static int client_send(char *addr_str, char *data, size_t datalen)
|
|||||||
|
|
||||||
res = sock_dtls_session_init(&dtls_sock, &remote, &session);
|
res = sock_dtls_session_init(&dtls_sock, &remote, &session);
|
||||||
if (res <= 0) {
|
if (res <= 0) {
|
||||||
|
sock_udp_close(&udp_sock);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user