Issue #3951 - Consider adding demand API to HTTP/2.
Using MathUtils.cappedAdd(). Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
e24ec133e7
commit
c59fc08e5a
|
@ -44,6 +44,7 @@ import org.eclipse.jetty.http2.frames.ResetFrame;
|
|||
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
|
||||
import org.eclipse.jetty.io.IdleTimeout;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.MathUtils;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -372,7 +373,7 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
|
|||
boolean proceed = false;
|
||||
synchronized (this)
|
||||
{
|
||||
dataDemand = addDemand(dataDemand, n);
|
||||
dataDemand = MathUtils.cappedAdd(dataDemand, n);
|
||||
if (!dataProcess)
|
||||
dataProcess = proceed = !dataQueue.isEmpty();
|
||||
if (LOG.isDebugEnabled())
|
||||
|
@ -414,18 +415,6 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
|
|||
}
|
||||
}
|
||||
|
||||
private static long addDemand(long x, long y)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Math.addExact(x, y);
|
||||
}
|
||||
catch (ArithmeticException e)
|
||||
{
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
private void onReset(ResetFrame frame, Callback callback)
|
||||
{
|
||||
remoteReset = true;
|
||||
|
|
Loading…
Reference in New Issue