chaoyoung commented on code in PR #16585:
URL: https://github.com/apache/dubbo/pull/16585#discussion_r4585749497
##########
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/h12/http2/GenericHttp2ServerTransportListener.java:
##########
@@ -186,6 +199,56 @@ protected void onMetadataCompletion(Http2Header metadata) {
}
}
+ @Override
+ protected Http2InputMessage onDataReceived(Http2InputMessage message) {
+ PendingInput input = newPendingInput(message);
+ synchronized (inputLock) {
+ pendingInputs.add(input);
+ if (inputClosed && processingInputs == 0) {
+ closeInput(input);
+ }
+ }
+ return new Http2InputMessageFrame(message.id(), input,
message.isEndStream());
+ }
+
+ protected PendingInput newPendingInput(Http2InputMessage message) {
+ return new PendingInput(message);
+ }
+
+ @Override
+ protected void doOnData(Http2InputMessage message) {
+ PendingInput input = (PendingInput) message.getBody();
+ synchronized (inputLock) {
+ if (inputClosed || input.closed.get()) {
+ closeInput(input);
+ return;
+ }
+ processingInputs++;
+ }
+ try {
+ super.doOnData(message);
+ } finally {
+ synchronized (inputLock) {
+ if (--processingInputs == 0 && inputClosed) {
+ closePendingInputs();
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onDataMessage(Http2InputMessage message,
HttpMessageListener listener) {
+ synchronized (inputLock) {
+ if (inputClosed) {
+ return;
+ }
+ // The decoder owns accepted input, including any bytes buffered
for later requests.
+ // Only inputs that have not crossed this boundary belong to the
transport registry.
+ pendingInputs.remove((PendingInput) message.getBody());
+ }
+ super.onDataMessage(message, listener);
Review Comment:
I added listenerFailureBeforeConsumptionReleasesInputOnce to check this path
directly. It also passes on the previous implementation: a callback that throws
before consuming the body reaches the existing onError(message, ...) cleanup
and releases the original body exactly once. I am retaining removal before the
callback. The decoder can already own buffered input while the callback is
still running; delaying removal until callback success would let concurrent
transport cancellation close decoder-owned input. The accepted-partial and
read-in-progress cancellation controls cover that distinction. The registry
therefore tracks only inputs that have not been handed to the message listener,
rather than claiming ownership until a successful callback return.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]