Commit 46b7c845 authored by Seppo Takalo's avatar Seppo Takalo Committed by Mahesh Mahadevan
Browse files

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: default avatarSeppo Takalo <seppo.takalo@nordicsemi.no>
parent 1ea569d7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ static void reset_internal_request(struct coap_client_internal_request *request)
	request->offset = 0;
	request->last_id = 0;
	request->last_response_id = -1;
	request->request_ongoing = false;
	reset_block_contexts(request);
}

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