You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/07/01 18:14:14 UTC

[tomcat] branch 9.0.x updated: Add debug logging to sendfile writes

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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 4371325  Add debug logging to sendfile writes
4371325 is described below

commit 4371325966350c938d206a1a3b085759fa99c7a3
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jul 1 19:12:55 2021 +0100

    Add debug logging to sendfile writes
---
 .../apache/coyote/http2/Http2AsyncUpgradeHandler.java  | 18 ++++++++++++++++++
 java/org/apache/coyote/http2/LocalStrings.properties   |  1 +
 webapps/docs/changelog.xml                             |  3 +++
 3 files changed, 22 insertions(+)

diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
index 08ee177..a79a7a8 100644
--- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
@@ -313,6 +313,11 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                 return SendfileState.ERROR;
             }
 
+            if (log.isDebugEnabled()) {
+                log.debug(sm.getString("upgradeHandler.sendfile.reservation", connectionId, sendfile.stream.getIdAsString(),
+                        Integer.valueOf(sendfile.connectionReservation), Integer.valueOf(sendfile.streamReservation)));
+            }
+
             // connectionReservation will always be smaller than or the same as
             // streamReservation
             int frameSize = Integer.min(getMaxFrameSize(), sendfile.connectionReservation);
@@ -331,6 +336,10 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                 }
             }
             if (writeable) {
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("upgradeHandler.writeBody", connectionId, sendfile.stream.getIdAsString(),
+                            Integer.toString(frameSize), Boolean.valueOf(finished)));
+                }
                 ByteUtil.set31Bits(header, 5, sendfile.stream.getIdAsInt());
                 sendfile.mappedBuffer.limit(sendfile.mappedBuffer.position() + frameSize);
                 socketWrapper.write(BlockingMode.SEMI_BLOCK, protocol.getWriteTimeout(),
@@ -377,6 +386,11 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                 return;
             }
 
+            if (log.isDebugEnabled()) {
+                log.debug(sm.getString("upgradeHandler.sendfile.reservation", connectionId, sendfile.stream.getIdAsString(),
+                        Integer.valueOf(sendfile.connectionReservation), Integer.valueOf(sendfile.streamReservation)));
+            }
+
             // connectionReservation will always be smaller than or the same as
             // streamReservation
             int frameSize = Integer.min(getMaxFrameSize(), sendfile.connectionReservation);
@@ -395,6 +409,10 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
                 }
             }
             if (writeable) {
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("upgradeHandler.writeBody", connectionId, sendfile.stream.getIdAsString(),
+                            Integer.toString(frameSize), Boolean.valueOf(finished)));
+                }
                 ByteUtil.set31Bits(header, 5, sendfile.stream.getIdAsInt());
                 sendfile.mappedBuffer.limit(sendfile.mappedBuffer.position() + frameSize);
                 socketWrapper.write(BlockingMode.SEMI_BLOCK, protocol.getWriteTimeout(),
diff --git a/java/org/apache/coyote/http2/LocalStrings.properties b/java/org/apache/coyote/http2/LocalStrings.properties
index 3b971a7..cf36ded 100644
--- a/java/org/apache/coyote/http2/LocalStrings.properties
+++ b/java/org/apache/coyote/http2/LocalStrings.properties
@@ -143,6 +143,7 @@ upgradeHandler.prunedPriority=Connection [{0}] Pruned unused stream [{1}] that m
 upgradeHandler.releaseBacklog=Connection [{0}], Stream [{1}] released from backlog
 upgradeHandler.reset.receive=Connection [{0}], Stream [{1}], Reset received due to [{2}]
 upgradeHandler.rst.debug=Connection [{0}], Stream [{1}], Error [{2}], Message [{3}],  RST (closing stream)
+upgradeHandler.sendfile.reservation=Connection [{0}], Stream [{1}], Connection reservation [{2}], Stream reservation [{3}] prior to sendfile write
 upgradeHandler.sendPrefaceFail=Connection [{0}], Failed to send preface to client
 upgradeHandler.socketCloseFailed=Error closing socket
 upgradeHandler.startRequestBodyFrame.result=Connection [{0}], Stream [{1}] startRequestBodyFrame returned [{2}]
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9c19ee9..7538ad1 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,9 @@
         checks both the stream and connection flow control windows before
         writing. (markt)
       </fix>
+      <add>
+        Add debug logging for writing an HTTP/2 response via sendfile. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Web applications">

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