Skip to content

Commit

Permalink
Update window using correct remaining() value (#4184)
Browse files Browse the repository at this point in the history
This commit fixes an issue where the receive window for the CRT client is
updated with the value of remaining() *after* it's been read, which is incorrect
as this will be 0 if the buffer has been fully consumed, which is it should be.
  • Loading branch information
dagnir committed Jul 13, 2023
1 parent 87b36dd commit 4639d41
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public int onResponseBody(ByteBuffer bodyBytesIn, long objectRangeStart, long ob
return 0;
}

int bytesReceived = bodyBytesIn.remaining();
CompletableFuture<Void> writeFuture = responsePublisher.send(bodyBytesIn);

writeFuture.whenComplete((result, failure) -> {
Expand All @@ -77,7 +78,7 @@ public int onResponseBody(ByteBuffer bodyBytesIn, long objectRangeStart, long ob
return;
}

metaRequest.incrementReadWindow(bodyBytesIn.remaining());
metaRequest.incrementReadWindow(bytesReceived);
});

// Returning 0 to disable flow control because we manually increase read window above
Expand Down

0 comments on commit 4639d41

Please sign in to comment.