This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new f9d77aafd8 Correctly record request start time
f9d77aafd8 is described below

commit f9d77aafd84804a534aa6dd7c31465acd94ed1b4
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 +---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java 
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index 22232913ac..2e6d0e885a 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -335,8 +335,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.
@@ -358,7 +356,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 a070909617..08b1fc8a02 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -157,9 +157,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());
     }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to