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 2022/06/06 09:05:15 UTC

[tomcat] branch 8.5.x updated (9de72137c0 -> da78c135e0)

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

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


    from 9de72137c0 Fix typo
     new 3e7ef99bcf Polish. NioEndpoint
     new da78c135e0 Replace the fixed message with endpoint.err.handshake

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/tomcat/util/net/NioEndpoint.java | 50 ++++++++++++------------
 1 file changed, 25 insertions(+), 25 deletions(-)


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


[tomcat] 01/02: Polish. NioEndpoint

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3e7ef99bcfe65307914ecb0a7ab889987d246863
Author: lihan <ao...@gmail.com>
AuthorDate: Thu Jun 2 16:57:39 2022 +0800

    Polish. NioEndpoint
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 48 ++++++++++++------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index a6eaac0b3a..c01e51d68a 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -563,6 +563,19 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
             }
         }
 
+        private PollerEvent createPollerEvent(NioSocketWrapper socketWrapper, int interestOps) {
+            PollerEvent r = null;
+            if (eventCache != null) {
+                r = eventCache.pop();
+            }
+            if (r == null) {
+                r = new PollerEvent(socketWrapper, interestOps);
+            } else {
+                r.reset(socketWrapper, interestOps);
+            }
+            return r;
+        }
+
         /**
          * Add specified socket and associated pool to the poller. The socket will
          * be added to a temporary array, and polled first after a maximum amount
@@ -574,16 +587,8 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
          *                    the Poller
          */
         public void add(NioSocketWrapper socketWrapper, int interestOps) {
-            PollerEvent r = null;
-            if (eventCache != null) {
-                r = eventCache.pop();
-            }
-            if (r == null) {
-                r = new PollerEvent(socketWrapper, interestOps);
-            } else {
-                r.reset(socketWrapper, interestOps);
-            }
-            addEvent(r);
+            PollerEvent pollerEvent = createPollerEvent(socketWrapper, interestOps);
+            addEvent(pollerEvent);
             if (close) {
                 processSocket(socketWrapper, SocketEvent.STOP, false);
             }
@@ -654,16 +659,8 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
          */
         public void register(final NioSocketWrapper socketWrapper) {
             socketWrapper.interestOps(SelectionKey.OP_READ);//this is what OP_REGISTER turns into.
-            PollerEvent event = null;
-            if (eventCache != null) {
-                event = eventCache.pop();
-            }
-            if (event == null) {
-                event = new PollerEvent(socketWrapper, OP_REGISTER);
-            } else {
-                event.reset(socketWrapper, OP_REGISTER);
-            }
-            addEvent(event);
+            PollerEvent pollerEvent = createPollerEvent(socketWrapper, OP_REGISTER);
+            addEvent(pollerEvent);
         }
 
         public void cancelledKey(SelectionKey sk, SocketWrapperBase<NioChannel> socketWrapper) {
@@ -963,12 +960,12 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
                             // Avoid duplicate stop calls
                             socketWrapper.interestOps(0);
                             cancelledKey(key, socketWrapper);
-                        } else if ((socketWrapper.interestOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ ||
-                                  (socketWrapper.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
+                        } else if (socketWrapper.interestOpsHas(SelectionKey.OP_READ) ||
+                                  socketWrapper.interestOpsHas(SelectionKey.OP_WRITE)) {
                             boolean readTimeout = false;
                             boolean writeTimeout = false;
                             // Check for read timeout
-                            if ((socketWrapper.interestOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
+                            if (socketWrapper.interestOpsHas(SelectionKey.OP_READ)) {
                                 long delta = now - socketWrapper.getLastRead();
                                 long timeout = socketWrapper.getReadTimeout();
                                 if (timeout > 0 && delta > timeout) {
@@ -976,7 +973,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
                                 }
                             }
                             // Check for write timeout
-                            if (!readTimeout && (socketWrapper.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
+                            if (!readTimeout && socketWrapper.interestOpsHas(SelectionKey.OP_WRITE)) {
                                 long delta = now - socketWrapper.getLastWrite();
                                 long timeout = socketWrapper.getWriteTimeout();
                                 if (timeout > 0 && delta > timeout) {
@@ -1052,6 +1049,9 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
         public Poller getPoller() { return poller; }
         public int interestOps() { return interestOps; }
         public int interestOps(int ops) { this.interestOps  = ops; return ops; }
+        public boolean interestOpsHas(int targetOp) {
+            return (this.interestOps() & targetOp) == targetOp;
+        }
 
         public void setSendfileData(SendfileData sf) { this.sendfileData = sf;}
         public SendfileData getSendfileData() { return this.sendfileData; }


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


[tomcat] 02/02: Replace the fixed message with endpoint.err.handshake

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit da78c135e02b25d88962a5a364694aada545cd33
Author: lihan <ao...@gmail.com>
AuthorDate: Fri Jun 3 22:57:19 2022 +0800

    Replace the fixed message with endpoint.err.handshake
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index c01e51d68a..70a1778338 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1677,7 +1677,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
                 } catch (IOException x) {
                     handshake = -1;
                     if (log.isDebugEnabled()) {
-                        log.debug("Error during SSL handshake",x);
+                        log.debug(sm.getString("endpoint.err.handshake"),x);
                     }
                 } catch (CancelledKeyException ckx) {
                     handshake = -1;


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