Skip to content

Commit 945598a

Browse files
committed
[nrf fromtree] net: lib: coap_client: Drop duplicate MID only after responding with Ack
Even if we receive duplicate confirmable message, we should still respond with the Ack. Just don't deliver the second callback. This is achieved by moving the MID deduplication to after Ack handling. Signed-off-by: Seppo Takalo <[email protected]> (cherry picked from commit c0eb260)
1 parent 675ac33 commit 945598a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

subsys/net/lib/coap/coap_client.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,6 @@ static int handle_response(struct coap_client *client, const struct coap_packet
781781
return 0;
782782
}
783783

784-
/* MID-based deduplication */
785-
if (response_id == internal_req->last_response_id) {
786-
LOG_WRN("Duplicate MID, dropping");
787-
goto fail;
788-
}
789-
790-
internal_req->last_response_id = response_id;
791-
792784
/* Received echo option */
793785
if (find_echo_option(response, &client->echo_option)) {
794786
/* Resend request with echo option */
@@ -847,13 +839,21 @@ static int handle_response(struct coap_client *client, const struct coap_packet
847839
}
848840
}
849841

842+
/* MID-based deduplication */
843+
if (response_id == internal_req->last_response_id) {
844+
LOG_WRN("Duplicate MID, dropping");
845+
return 0;
846+
}
847+
848+
internal_req->last_response_id = response_id;
849+
850850
if (!internal_req->request_ongoing) {
851851
if (internal_req->is_observe) {
852852
(void) send_rst(client, response);
853853
return 0;
854854
}
855855
LOG_DBG("Drop request, already handled");
856-
goto fail;
856+
return 0;
857857
}
858858

859859
if (internal_req->pending.timeout != 0) {

0 commit comments

Comments
 (0)