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/04 08:30:08 UTC
(httpcomponents-core) branch 5.3.x updated (e3f7f02bf -> 2a83df38b)
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a change to branch 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
from e3f7f02bf Minor performance optimization in handling of HEAD requests by the H2 transport
new d31d00000 HTTPCORE-774: fixed a race condition caused by concurrent update of the connection input window to the max value.
new 2a83df38b HTTPCORE-774: 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.
Summary of changes:
.../impl/nio/AbstractH2StreamMultiplexer.java | 24 ++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
(httpcomponents-core) 02/02: HTTPCORE-774: 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 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit 2a83df38b579b12d1017c40e07c6480e4da9b42d
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Jan 3 10:05:07 2025 +0100
HTTPCORE-774: 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: HTTPCORE-774: 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 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit d31d0000084d1ffdd37a9596b53e2aa7779451bc
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Jan 3 09:58:35 2025 +0100
HTTPCORE-774: 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);
}