You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2025/01/03 09:30:57 UTC
(httpcomponents-core) branch HTTPCLIENT-2352 created (now da99c2bae)
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a change to branch HTTPCLIENT-2352
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
at da99c2bae HTTPCLIENT-2352: update window management improvements
This branch includes the following new commits:
new ce44602f7 HTTPCLIENT-2352: fixed a race condition caused by concurrent update of the connection input window to the max value.
new da99c2bae HTTPCLIENT-2352: update window management improvements
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(httpcomponents-core) 02/02: HTTPCLIENT-2352: update window management improvements
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch HTTPCLIENT-2352
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit da99c2bae0e255a8d1d20ca345abbf44ddde5700
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Jan 3 10:05:07 2025 +0100
HTTPCLIENT-2352: update window management improvements
---
.../impl/nio/AbstractH2StreamMultiplexer.java | 23 +++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
index e6b6c7a0c..f7de865a6 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
@@ -188,6 +188,7 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
abstract H2StreamHandler createRemotelyInitiatedStream(
H2StreamChannel channel,
+
HttpProcessor httpProcessor,
BasicHttpConnectionMetrics connMetrics,
HandlerFactory<AsyncPushConsumer> pushHandlerFactory) throws IOException;
@@ -211,6 +212,15 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
}
}
+ private int updateWindowMax(final AtomicInteger window) throws ArithmeticException {
+ for (;;) {
+ final int current = window.get();
+ if (window.compareAndSet(current, Integer.MAX_VALUE)) {
+ return Integer.MAX_VALUE - current;
+ }
+ }
+ }
+
private int updateInputWindow(
final int streamId, final AtomicInteger window, final int delta) throws ArithmeticException {
final int newSize = updateWindow(window, delta);
@@ -371,9 +381,9 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
final int remainingCapacity = Integer.MAX_VALUE - streamWinSize;
final int chunk = Math.min(inputCapacity, remainingCapacity);
if (chunk != 0) {
+ updateInputWindow(streamId, inputWindow, chunk);
final RawFrame windowUpdateFrame = frameFactory.createWindowUpdate(streamId, chunk);
commitFrame(windowUpdateFrame);
- updateInputWindow(streamId, inputWindow, chunk);
}
}
}
@@ -412,7 +422,7 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
commitFrame(settingsFrame);
localSettingState = SettingsHandshake.TRANSMITTED;
- maximizeConnWindow(connInputWindow.get());
+ maximizeWindow(0, connInputWindow);
if (streamListener != null) {
final int initInputWindow = connInputWindow.get();
@@ -1024,7 +1034,7 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
}
final int connWinSize = updateInputWindow(0, connInputWindow, -frameLength);
if (connWinSize < CONNECTION_WINDOW_LOW_MARK) {
- maximizeConnWindow(connWinSize);
+ maximizeWindow(0, connInputWindow);
}
}
if (stream.isRemoteClosed()) {
@@ -1039,12 +1049,11 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
stream.consumeData(payload);
}
- private void maximizeConnWindow(final int connWinSize) throws IOException {
- final int delta = Integer.MAX_VALUE - connWinSize;
+ private void maximizeWindow(final int streamId, final AtomicInteger window) throws IOException {
+ final int delta = updateWindowMax(window);
if (delta > 0) {
- final RawFrame windowUpdateFrame = frameFactory.createWindowUpdate(0, delta);
+ final RawFrame windowUpdateFrame = frameFactory.createWindowUpdate(streamId, delta);
commitFrame(windowUpdateFrame);
- updateInputWindow(0, connInputWindow, delta);
}
}
(httpcomponents-core) 01/02: HTTPCLIENT-2352: fixed a race condition caused by concurrent update of the connection input window to the max value.
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch HTTPCLIENT-2352
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit ce44602f7a7a72b12f3c5e69d7db827d8a2337e5
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Jan 3 09:58:35 2025 +0100
HTTPCLIENT-2352: fixed a race condition caused by concurrent update of the connection input window to the max value.
---
.../org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
index 729cc75b0..e6b6c7a0c 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2StreamMultiplexer.java
@@ -1441,7 +1441,6 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
if (remoteEndStream) {
return;
}
- incrementInputCapacity(0, connInputWindow, increment);
incrementInputCapacity(id, inputWindow, increment);
}