Skip to content

Commit

Permalink
Fix response destination on retransmission with identities not based on
Browse files Browse the repository at this point in the history
the ip-address.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
  • Loading branch information
boaks committed Mar 13, 2024
1 parent fb404b8 commit 91a8c47
Showing 1 changed file with 20 additions and 9 deletions.
Expand Up @@ -232,20 +232,31 @@ private void prepareRetransmission(final Exchange exchange, final Retransmission
public void receiveRequest(Exchange exchange, Request request) {

if (request.isDuplicate()) {
long send = exchange.getSendNanoTimestamp();
if (send == 0 || (send - request.getNanoTimestamp()) > 0) {
// received before response was sent
int count = counter.incrementAndGet();
LOGGER.debug("{}: {} duplicate request {}, server sent response delayed, ignore request", count,
exchange, request);
return;
Response previousResponse = exchange.getCurrentResponse();
Request previousRequest = exchange.getCurrentRequest();
if (previousResponse != null) {
if (previousResponse.getSendError() == null) {
long send = exchange.getSendNanoTimestamp();
if (send == 0 || (send - request.getNanoTimestamp()) > 0) {
// received before response was sent
int count = counter.incrementAndGet();
LOGGER.debug("{}: {} duplicate request {}, server sent response delayed, ignore request", count,
exchange, request);
return;
}
} else {
previousResponse.setSendError(null);
}
}

// Request is a duplicate, so resend ACK, RST or response
exchange.retransmitResponse();
Request previousRequest = exchange.getCurrentRequest();
Response previousResponse = exchange.getCurrentResponse();
if (previousResponse != null) {
EndpointContext sourceContext = request.getSourceContext();
if (!previousResponse.getEffectiveDestinationContext().getPeerAddress()
.equals(sourceContext.getPeerAddress())) {
previousResponse.setEffectiveDestinationContext(sourceContext);
}
Type type = previousResponse.getType();
if (type == Type.NON || type == Type.CON) {
if (request.acknowledge()) {
Expand Down

0 comments on commit 91a8c47

Please sign in to comment.