Skip to content

Commit 46b7c84

Browse files
SeppoTakalommahadevan108
authored andcommitted
net: lib: coap_client: Release internal request when failed to send
When transmission of first request fails, reset the internal request buffer as there is no ongoing CoAP transaction. Application can deal with the failure. Signed-off-by: Seppo Takalo <[email protected]>
1 parent 1ea569d commit 46b7c84

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

subsys/net/lib/coap/coap_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static void reset_internal_request(struct coap_client_internal_request *request)
6969
request->offset = 0;
7070
request->last_id = 0;
7171
request->last_response_id = -1;
72+
request->request_ongoing = false;
7273
reset_block_contexts(request);
7374
}
7475

@@ -426,6 +427,7 @@ int coap_client_req(struct coap_client *client, int sock, const struct sockaddr
426427
&client->address, client->socklen);
427428
if (ret < 0) {
428429
LOG_ERR("Transmission failed: %d", errno);
430+
reset_internal_request(internal_req);
429431
} else {
430432
/* Do not return the number of bytes sent */
431433
ret = 0;

0 commit comments

Comments
 (0)