Skip to content

Commit

Permalink
Review feedback, renamed 'received' parameter to 'processed'
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuch committed Jan 10, 2025
1 parent 812e399 commit 73f0e94
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,24 @@ abstract class WindowUpdateSender {
* the caller wants to buffer.
*/
boolean canBufferUnprocessedBytes(int len) {
long buffered, rcv;
long buffered, processed;
// get received before unprocessed in order to avoid counting
// unprocessed bytes that might get unbuffered asynchronously
// twice.
rcv = received.get();
processed = received.get();
buffered = unprocessed.addAndGet(len);
return !checkWindowSizeExceeded(rcv, buffered);
return !checkWindowSizeExceeded(processed, buffered);
}

// adds the provided amount to the amount of already
// received and processed bytes and checks whether the
// processed and processed bytes and checks whether the
// flow control window is exceeded. If so, take
// corrective actions and return true.
private boolean checkWindowSizeExceeded(long received, long len) {
private boolean checkWindowSizeExceeded(long processed, long len) {
// because windowSize is bound by Integer.MAX_VALUE
// we will never reach the point where received.get() + len
// could overflow
long rcv = received + len;
long rcv = processed + len;
return rcv > windowSize && windowSizeExceeded(rcv);
}

Expand Down

0 comments on commit 73f0e94

Please sign in to comment.