You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2019/03/27 21:38:58 UTC

[tomcat] branch master updated: Cleanups

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4edcbe8  Cleanups
4edcbe8 is described below

commit 4edcbe8be12a8014ce9bf0d8b0558df4caa443d7
Author: remm <re...@apache.org>
AuthorDate: Wed Mar 27 22:38:47 2019 +0100

    Cleanups
    
    Add some comments. Remove dead method override in HTTP/2.
---
 .../apache/coyote/http2/Http2AsyncUpgradeHandler.java   |  7 -------
 java/org/apache/tomcat/util/net/Nio2Endpoint.java       | 17 +++++++++--------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
index 15098f0..91bd857 100644
--- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
@@ -264,13 +264,6 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
     }
 
     @Override
-    protected void processWrites() throws IOException {
-        if (socketWrapper.isWritePending()) {
-            socketWrapper.registerWriteInterest();
-        }
-    }
-
-    @Override
     protected SendfileState processSendfile(SendfileData sendfile) {
         if (sendfile != null) {
             try {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index b27ca4e..8ebbe6f 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -714,22 +714,22 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS
         @Override
         public boolean isReadyForRead() throws IOException {
             synchronized (readCompletionHandler) {
+                // A notification has been sent, it is possible to read at least once
                 if (readNotify) {
                     return true;
                 }
-
+                // If a read is pending, reading is not possible until a notification is sent
                 if (!readPending.tryAcquire()) {
                     readInterest = true;
                     return false;
                 }
-
+                // It is possible to read directly from the buffer contents
                 if (!socketBufferHandler.isReadBufferEmpty()) {
                     readPending.release();
                     return true;
                 }
-
-                int nRead = fillReadBuffer(false);
-                boolean isReady = nRead > 0;
+                // Try to read some data
+                boolean isReady = fillReadBuffer(false) > 0;
                 if (!isReady) {
                     readInterest = true;
                 }
@@ -741,20 +741,21 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS
         @Override
         public boolean isReadyForWrite() {
             synchronized (writeCompletionHandler) {
+                // A notification has been sent, it is possible to write at least once
                 if (writeNotify) {
                     return true;
                 }
-
+                // If a write is pending, writing is not possible until a notification is sent
                 if (!writePending.tryAcquire()) {
                     writeInterest = true;
                     return false;
                 }
-
+                // If the buffer is empty, it is possible to write to it 
                 if (socketBufferHandler.isWriteBufferEmpty() && nonBlockingWriteBuffer.isEmpty()) {
                     writePending.release();
                     return true;
                 }
-
+                // Try to flush all data
                 boolean isReady = !flushNonBlockingInternal(true);
                 if (!isReady) {
                     writeInterest = true;


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