1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cord: include gcoap_req_send returning 0 in error

gcoap_req_send returns 0 if it was unable to send the CoAP request. CoRD
did not include that case in the return code checks. This changes CoRD
to include it and drop the registration if CoAP could not send the
request. The old behaviour made the CoRD thread lock up.
This commit is contained in:
Koen Zandberg 2023-03-13 11:49:37 +01:00
parent 743ae3f095
commit 19ff949404
No known key found for this signature in database
GPG Key ID: BA1718B37D79F51C

View File

@ -151,8 +151,10 @@ static int _update_remove(unsigned code, gcoap_resp_handler_t handle)
ssize_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
/* send request */
gcoap_req_send(buf, pkt_len, &_rd_remote, handle, NULL);
ssize_t send_len = gcoap_req_send(buf, pkt_len, &_rd_remote, handle, NULL);
if (send_len <= 0) {
return CORD_EP_ERR;
}
/* synchronize response */
return _sync();
}
@ -224,7 +226,7 @@ static int _discover_internal(const sock_udp_ep_t *remote,
coap_opt_add_uri_query(&pkt, "rt", "core.rd");
size_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
res = gcoap_req_send(buf, pkt_len, remote, _on_discover, NULL);
if (res < 0) {
if (res <= 0) {
return CORD_EP_ERR;
}
return _sync();
@ -295,7 +297,7 @@ int cord_ep_register(const sock_udp_ep_t *remote, const char *regif)
/* send out the request */
res = gcoap_req_send(buf, pkt_len, remote, _on_register, NULL);
if (res < 0) {
if (res <= 0) {
retval = CORD_EP_ERR;
goto end;
}