This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 9ffba57778 Correctly record request start time 9ffba57778 is described below commit 9ffba577785c66d7e2481c46ff9de2ff9b96f8ec Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Sep 24 15:41:43 2024 +0100 Correctly record request start time (System.nanoTime() can return negative values) --- java/org/apache/coyote/http11/Http11InputBuffer.java | 5 ++--- java/org/apache/coyote/http2/Stream.java | 4 +--- webapps/docs/changelog.xml | 4 ++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java b/java/org/apache/coyote/http11/Http11InputBuffer.java index af34736a2d..8ea6078f67 100644 --- a/java/org/apache/coyote/http11/Http11InputBuffer.java +++ b/java/org/apache/coyote/http11/Http11InputBuffer.java @@ -346,8 +346,6 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler wrapper.setReadTimeout(keepAliveTimeout); } if (!fill(false)) { - // A read is pending, so no longer in initial state - parsingRequestLinePhase = 1; return false; } // At least one byte of the request has been received. @@ -369,7 +367,8 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler } // Set the start time once we start reading data (even if it is // just skipping blank lines) - if (request.getStartTimeNanos() < 0) { + if (parsingRequestLinePhase == 0) { + parsingRequestLinePhase = 1; request.setStartTimeNanos(System.nanoTime()); } chr = byteBuffer.get(); diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java index 2b81241f4d..b2a36fc2e2 100644 --- a/java/org/apache/coyote/http2/Stream.java +++ b/java/org/apache/coyote/http2/Stream.java @@ -161,9 +161,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter { this.coyoteResponse.setOutputBuffer(http2OutputBuffer); this.coyoteRequest.setResponse(coyoteResponse); this.coyoteRequest.protocol().setString("HTTP/2.0"); - if (this.coyoteRequest.getStartTimeNanos() < 0) { - this.coyoteRequest.setStartTimeNanos(System.nanoTime()); - } + this.coyoteRequest.setStartTimeNanos(System.nanoTime()); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 4892221b5e..4830b54ce5 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -153,6 +153,10 @@ input. Prior to this change, the output may have wrong by one second in some cases. Pull request <pr>751</pr> provided by Chenjp. (markt) </fix> + <fix> + Request start time may not have been accurately recorded for HTTP/1.1 + requests preceded by a large number of blank lines. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org