Cancel retransmission of messages when response has arrived.

In case the ACK of a separate message is lost, the request would be
retransmitted until the maximum number of transmissions is reached because
the response usually has a different messsage id. The matching at this
point is done based on the response's source address and token.
This commit is contained in:
Olaf Bergmann committed 2014-03-06 15:38:37 +00:00
1 parent ed9c7ee560
commit 37699fd058
1 file changed
+13 -5
+13 -5
View File
@@ -1448,12 +1448,20 @@ handle_response(coap_context_t *context,
/* First acknowledge incoming response if it is a CON message. Note
* that the necessary checks are done in coap_send_ack(). */
if (rcvd->pdu->hdr->code == COAP_RESPONSE_CODE(731)
&& !coap_cancel(context, rcvd)) {
coap_send_rst(context, &rcvd->remote, rcvd->pdu);
if (rcvd->pdu->hdr->code == COAP_RESPONSE_CODE(731)) {
if (!coap_cancel(context, rcvd)) {
coap_send_rst(context, &rcvd->remote, rcvd->pdu);
} else {
coap_send_ack(context, &rcvd->remote, rcvd->pdu);
}
} else {
coap_send_ack(context, &rcvd->remote, rcvd->pdu);
/* In a lossy context, the ACK of a separate response may have
* been lost, so we need to stop retransmitting requests with the
* same token.
*/
coap_cancel_all_messages(context, &rcvd->remote,
rcvd->pdu->hdr->token,
rcvd->pdu->hdr->token_length);
}
/* Call application-specific reponse handler when available. */