From 2b800a900539e3195433d033f54e03d30fe3b482 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 24 Jan 2024 11:19:06 +0100 Subject: [PATCH] fix over-releases and add comment Signed-off-by: Ludovic Orban --- .../server/internal/ServerFCGIConnection.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java index c313ddd54de6..dbcb3e405d91 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/ServerFCGIConnection.java @@ -180,12 +180,12 @@ public void onFillable() LOG.debug("Read {} bytes from {} {}", read, getEndPoint(), this); if (read > 0) { + // The networkBuffer cannot be released immediately after parse() + // even if the buffer has been fully consumed because releaseInputBuffer() + // must be called as the last release for it to be able to null out the + // networkBuffer field exactly when the latter isn't used anymore. if (parse(networkBuffer.getByteBuffer())) - { - if (!networkBuffer.hasRemaining()) - releaseInputBuffer(); break; - } } else if (read == 0) { @@ -230,12 +230,12 @@ void parseAndFill() // See also HttpConnection.parseAndFillForContent(). while (stream != null) { + // The networkBuffer cannot be released immediately after parse() + // even if the buffer has been fully consumed because releaseInputBuffer() + // must be called as the last release for it to be able to null out the + // networkBuffer field exactly when the latter isn't used anymore. if (parse(networkBuffer.getByteBuffer())) - { - if (!networkBuffer.hasRemaining()) - releaseInputBuffer(); break; - } // Check if the request was completed by the parsing. if (stream == null || fillInputBuffer() <= 0)