diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java index fffa5592d627..f562a5a7beee 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/BeginRequestContentParser.java @@ -16,6 +16,7 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.fcgi.FCGI; +import org.eclipse.jetty.util.NanoTime; /** *
Parser for the BEGIN_REQUEST frame content.
@@ -34,6 +35,7 @@ public class BeginRequestContentParser extends ContentParser private int cursor; private int role; private int flags; + private long beginNanoTime; public BeginRequestContentParser(HeaderParser headerParser, ServerParser.Listener listener) { @@ -41,6 +43,11 @@ public BeginRequestContentParser(HeaderParser headerParser, ServerParser.Listene this.listener = listener; } + public long getBeginNanoTime() + { + return beginNanoTime; + } + @Override public Result parse(ByteBuffer buffer) { @@ -50,6 +57,7 @@ public Result parse(ByteBuffer buffer) { case ROLE: { + beginNanoTime = NanoTime.now(); if (buffer.remaining() >= 2) { role = buffer.getShort(); diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ServerParser.java b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ServerParser.java index 4abe5236cd1e..c04fcd6d0372 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ServerParser.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-client/src/main/java/org/eclipse/jetty/fcgi/parser/ServerParser.java @@ -29,6 +29,12 @@ public ServerParser(Listener listener) contentParsers.put(FCGI.FrameType.STDIN, new StreamContentParser(headerParser, FCGI.StreamType.STD_IN, listener)); } + public long getBeginNanoTime() + { + BeginRequestContentParser contentParser = (BeginRequestContentParser)contentParsers.get(FCGI.FrameType.BEGIN_REQUEST); + return contentParser.getBeginNanoTime(); + } + @Override protected ContentParser findContentParser(FCGI.FrameType frameType) { diff --git a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java index ba8b07f62dc9..bcf075926347 100644 --- a/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java +++ b/jetty-core/jetty-fcgi/jetty-fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/internal/HttpStreamOverFCGI.java @@ -35,7 +35,6 @@ import org.eclipse.jetty.server.HttpStream; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.thread.Invocable; @@ -106,7 +105,8 @@ public void onHeaders() { String pathQuery = URIUtil.addPathQuery(_path, _query); HttpScheme scheme = StringUtil.isEmpty(_secure) ? HttpScheme.HTTP : HttpScheme.HTTPS; - MetaData.Request request = new MetaData.Request(NanoTime.now(), _method, scheme.asString(), hostPort, pathQuery, HttpVersion.fromString(_version), _headers, -1); // TODO #9900 make beginNanoTime accurate + ServerFCGIConnection serverFCGIConnection = (ServerFCGIConnection)getHttpChannel().getConnectionMetaData().getConnection(); + MetaData.Request request = new MetaData.Request(serverFCGIConnection.getBeginNanoTime(), _method, scheme.asString(), hostPort, pathQuery, HttpVersion.fromString(_version), _headers, -1); // TODO #9900 make beginNanoTime accurate Runnable task = _httpChannel.onRequest(request); _allHeaders.forEach(field -> _httpChannel.getRequest().setAttribute(field.getName(), field.getValue())); // TODO: here we just execute the task. 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 25b85a60fca3..17ac56fa952f 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 @@ -70,6 +70,11 @@ public ServerFCGIConnection(Connector connector, EndPoint endPoint, HttpConfigur this.id = StringUtil.randomAlphaNumeric(16); } + public long getBeginNanoTime() + { + return parser.getBeginNanoTime(); + } + Flusher getFlusher() { return flusher;