You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Kaven Stone (Jira)" <ji...@apache.org> on 2021/11/28 11:16:00 UTC

[jira] [Created] (HTTPCORE-701) A little confuse for the H2 update window function

Kaven Stone created HTTPCORE-701:
------------------------------------

             Summary: A little confuse for the H2 update window function
                 Key: HTTPCORE-701
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-701
             Project: HttpComponents HttpCore
          Issue Type: Improvement
          Components: HttpCore
    Affects Versions: 5.1
            Reporter: Kaven Stone


I just read the update window logic for http2, and the function is a little confuse for me.
 # why here should use the for (;;) here? what the purpose?
 # for the two TODO:  The first TODO, it revert the min value as to the the max value, this if for what situation?
 # The seconde TODO:  needs to be removed ,  and that will remove what?

 

The soure code in httpcore5-h2\src\main\java\org\apache\hc\core5\http2\impl\nio\AbstractH2StreamMultiplexer.java is as below:

private int updateWindow(final AtomicInteger window, final int delta) throws ArithmeticException {
for (;;) {
final int current = window.get();
long newValue = (long) current + delta;

//TODO: work-around for what looks like a bug in Ngnix (1.11)
// Tolerate if the update window exceeded by one
if (newValue == 0x80000000L) {
newValue = Integer.MAX_VALUE;
}
//TODO: needs to be removed

if (Math.abs(newValue) > 0x7fffffffL) {
throw new ArithmeticException("Update causes flow control window to exceed " + Integer.MAX_VALUE);
}
if (window.compareAndSet(current, (int) newValue)) {
return (int) newValue;
}
}
}

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org