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 2020/10/08 20:17:23 UTC

[tomcat] branch 8.5.x updated (c656fbb -> 9219962)

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 c656fbb  Fix HTTP/2 window updates with zero padding. Found via CI tests
     new 716142c  Align wiht 9.0.x. No funcitonal change.
     new 9219962  Align with 9.0.x. No funcitonal change.

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:
 .../buildutil/translate/BackportEnglish.java       |  2 +-
 .../apache/tomcat/buildutil/translate/Utils.java   |  2 +-
 java/org/apache/tomcat/util/net/NioEndpoint.java   | 84 ++++++++++++----------
 3 files changed, 49 insertions(+), 39 deletions(-)


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


[tomcat] 01/02: Align wiht 9.0.x. No funcitonal change.

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 716142cf21ad64a2a9979c568fad4ec54c713b21
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 8 19:34:29 2020 +0100

    Align wiht 9.0.x. No funcitonal change.
---
 .../buildutil/translate/BackportEnglish.java       |  2 +-
 .../apache/tomcat/buildutil/translate/Utils.java   |  2 +-
 java/org/apache/tomcat/util/net/NioEndpoint.java   | 67 ++++++++++++----------
 3 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java b/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
index fb43d84..9a0c7ae 100644
--- a/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
+++ b/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
@@ -33,7 +33,7 @@ public class BackportEnglish extends BackportBase {
 
 
     public static void main(String... args) throws IOException {
-        // Exclude keys known to be different between 9.0.x and 8.5.x
+        // Exclude keys known to be different between 8.5.x and 7.0.x
         keysToExclude.add("java.org.apache.catalina.manager.zzz.htmlManagerServlet.deployPath");
         keysToExclude.add("java.org.apache.catalina.mbeans.zzz.jmxRemoteLifecycleListener.deprecated");
         keysToExclude.add("java.org.apache.catalina.session.zzz.managerBase.contextNull");
diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java b/java/org/apache/tomcat/buildutil/translate/Utils.java
index 5eb015f..63d3947 100644
--- a/java/org/apache/tomcat/buildutil/translate/Utils.java
+++ b/java/org/apache/tomcat/buildutil/translate/Utils.java
@@ -73,7 +73,7 @@ public class Utils {
         if (result.contains("[{0}]")) {
             result = FIX_SINGLE_QUOTE.matcher(result).replaceAll("''");
         }
-        return result;
+        return result.trim();
     }
 
 
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index a70faef..32a5c4d 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -90,7 +90,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
     private volatile ServerSocketChannel serverSock = null;
 
     /**
-     *
+     * Stop latch used to wait for poller stop
      */
     private volatile CountDownLatch stopLatch = null;
 
@@ -150,8 +150,9 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
     public int getPollerThreadCount() { return pollerThreadCount; }
 
     private long selectorTimeout = 1000;
-    public void setSelectorTimeout(long timeout){ this.selectorTimeout = timeout;}
-    public long getSelectorTimeout(){ return this.selectorTimeout; }
+    public void setSelectorTimeout(long timeout) { this.selectorTimeout = timeout;}
+    public long getSelectorTimeout() { return this.selectorTimeout; }
+
     /**
      * The socket poller.
      */
@@ -187,6 +188,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
 
 
     // --------------------------------------------------------- Public Methods
+
     /**
      * Number of keep-alive sockets.
      *
@@ -248,6 +250,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
         selectorPool.open();
     }
 
+
     /**
      * Start the NIO endpoint, creating acceptor, poller threads.
      */
@@ -266,7 +269,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                     socketProperties.getBufferPool());
 
             // Create worker collection
-            if ( getExecutor() == null ) {
+            if (getExecutor() == null) {
                 createExecutor();
             }
 
@@ -679,7 +682,9 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
 
         private void addEvent(PollerEvent event) {
             events.offer(event);
-            if ( wakeupCounter.incrementAndGet() == 0 ) selector.wakeup();
+            if (wakeupCounter.incrementAndGet() == 0) {
+                selector.wakeup();
+            }
         }
 
         /**
@@ -694,8 +699,11 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
          */
         public void add(final NioChannel socket, final int interestOps) {
             PollerEvent r = eventCache.pop();
-            if ( r==null) r = new PollerEvent(socket,null,interestOps);
-            else r.reset(socket,null,interestOps);
+            if (r == null) {
+                r = new PollerEvent(socket,null,interestOps);
+            } else {
+                r.reset(socket,null,interestOps);
+            }
             addEvent(r);
             if (close) {
                 NioEndpoint.NioSocketWrapper ka = (NioEndpoint.NioSocketWrapper)socket.getAttachment();
@@ -823,8 +831,8 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                     if (!close) {
                         hasEvents = events();
                         if (wakeupCounter.getAndSet(-1) > 0) {
-                            //if we are here, means we have other stuff to do
-                            //do a non blocking select
+                            // If we are here, means we have other stuff to do
+                            // Do a non blocking select
                             keyCount = selector.selectNow();
                         } else {
                             keyCount = selector.select(selectorTimeout);
@@ -846,8 +854,10 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                     log.error("",x);
                     continue;
                 }
-                //either we timed out or we woke up, process events first
-                if ( keyCount == 0 ) hasEvents = (hasEvents | events());
+                // Either we timed out or we woke up, process events first
+                if (keyCount == 0) {
+                    hasEvents = (hasEvents | events());
+                }
 
                 Iterator<SelectionKey> iterator =
                     keyCount > 0 ? selector.selectedKeys().iterator() : null;
@@ -855,27 +865,27 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                 // any active event.
                 while (iterator != null && iterator.hasNext()) {
                     SelectionKey sk = iterator.next();
-                    NioSocketWrapper attachment = (NioSocketWrapper)sk.attachment();
+                    NioSocketWrapper socketWrapper = (NioSocketWrapper) sk.attachment();
                     // Attachment may be null if another thread has called
                     // cancelledKey()
-                    if (attachment == null) {
+                    if (socketWrapper == null) {
                         iterator.remove();
                     } else {
                         iterator.remove();
-                        processKey(sk, attachment);
+                        processKey(sk, socketWrapper);
                     }
-                }//while
+                }
 
-                //process timeouts
+                // Process timeouts
                 timeout(keyCount,hasEvents);
-            }//while
+            }
 
             getStopLatch().countDown();
         }
 
         protected void processKey(SelectionKey sk, NioSocketWrapper attachment) {
             try {
-                if ( close ) {
+                if (close) {
                     cancelledKey(sk);
                 } else if ( sk.isValid() && attachment != null ) {
                     if (sk.isReadable() || sk.isWritable() ) {
@@ -901,10 +911,10 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                         }
                     }
                 } else {
-                    //invalid key
+                    // Invalid key
                     cancelledKey(sk);
                 }
-            } catch ( CancelledKeyException ckx ) {
+            } catch (CancelledKeyException ckx) {
                 cancelledKey(sk);
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
@@ -934,10 +944,10 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                 // Configure output channel
                 sc = socketWrapper.getSocket();
                 // TLS/SSL channel is slightly different
-                WritableByteChannel wc = ((sc instanceof SecureNioChannel)?sc:sc.getIOChannel());
+                WritableByteChannel wc = ((sc instanceof SecureNioChannel) ? sc : sc.getIOChannel());
 
                 // We still have data in the buffer
-                if (sc.getOutboundRemaining()>0) {
+                if (sc.getOutboundRemaining() > 0) {
                     if (sc.flushOutbound()) {
                         socketWrapper.updateLastWrite();
                     }
@@ -958,7 +968,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                 }
                 if (sd.length <= 0 && sc.getOutboundRemaining()<=0) {
                     if (log.isDebugEnabled()) {
-                        log.debug("Send file complete for: "+sd.fileName);
+                        log.debug("Send file complete for: " + sd.fileName);
                     }
                     socketWrapper.setSendfileData(null);
                     try {
@@ -990,7 +1000,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                             if (log.isDebugEnabled()) {
                                 log.debug("Connection is keep alive, registering back for OP_READ");
                             }
-                            reg(sk,socketWrapper,SelectionKey.OP_READ);
+                            reg(sk, socketWrapper, SelectionKey.OP_READ);
                             break;
                         }
                         }
@@ -1044,7 +1054,6 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
             if (nextExpiration > 0 && (keyCount > 0 || hasEvents) && (now < nextExpiration) && !close) {
                 return;
             }
-            //timeout
             int keycount = 0;
             try {
                 for (SelectionKey key : selector.keys()) {
@@ -1081,15 +1090,16 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
                                 }
                             }
                         }
-                    }catch ( CancelledKeyException ckx ) {
+                    } catch (CancelledKeyException ckx) {
                         cancelledKey(key);
                     }
-                }//for
+                }
             } catch (ConcurrentModificationException cme) {
                 // See https://bz.apache.org/bugzilla/show_bug.cgi?id=57943
                 log.warn(sm.getString("endpoint.nio.timeoutCme"), cme);
             }
-            long prevExp = nextExpiration; //for logging purposes only
+            // For logging purposes only
+            long prevExp = nextExpiration;
             nextExpiration = System.currentTimeMillis() +
                     socketProperties.getTimeoutInterval();
             if (log.isTraceEnabled()) {
@@ -1162,7 +1172,6 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
         public void updateLastRead() { lastRead = System.currentTimeMillis(); }
         public long getLastRead() { return lastRead; }
 
-
         @Override
         public boolean isReadyForRead() throws IOException {
             socketBufferHandler.configureReadBufferForRead();


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


[tomcat] 02/02: Align with 9.0.x. No funcitonal change.

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 9219962dd4a37cc256a99363734abb7f43e47c27
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 8 19:49:26 2020 +0100

    Align with 9.0.x. No funcitonal change.
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 32a5c4d..9b8c281 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1032,14 +1032,14 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
             }
         }
 
-        protected void unreg(SelectionKey sk, NioSocketWrapper attachment, int readyOps) {
-            //this is a must, so that we don't have multiple threads messing with the socket
-            reg(sk,attachment,sk.interestOps()& (~readyOps));
+        protected void unreg(SelectionKey sk, NioSocketWrapper socketWrapper, int readyOps) {
+            // This is a must, so that we don't have multiple threads messing with the socket
+            reg(sk, socketWrapper, sk.interestOps() & (~readyOps));
         }
 
-        protected void reg(SelectionKey sk, NioSocketWrapper attachment, int intops) {
+        protected void reg(SelectionKey sk, NioSocketWrapper socketWrapper, int intops) {
             sk.interestOps(intops);
-            attachment.interestOps(intops);
+            socketWrapper.interestOps(intops);
         }
 
         protected void timeout(int keyCount, boolean hasEvents) {
@@ -1132,9 +1132,9 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
             socketBufferHandler = channel.getBufHandler();
         }
 
-        public Poller getPoller() { return poller;}
+        public Poller getPoller() { return poller; }
         public void setPoller(Poller poller){this.poller = poller;}
-        public int interestOps() { return interestOps;}
+        public int interestOps() { return interestOps; }
         public int interestOps(int ops) { this.interestOps  = ops; return ops; }
         public CountDownLatch getReadLatch() { return readLatch; }
         public CountDownLatch getWriteLatch() { return writeLatch; }
@@ -1165,7 +1165,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
         public void awaitWriteLatch(long timeout, TimeUnit unit) throws InterruptedException { awaitLatch(writeLatch,timeout,unit);}
 
         public void setSendfileData(SendfileData sf) { this.sendfileData = sf;}
-        public SendfileData getSendfileData() { return this.sendfileData;}
+        public SendfileData getSendfileData() { return this.sendfileData; }
 
         public void updateLastWrite() { lastWrite = System.currentTimeMillis(); }
         public long getLastWrite() { return lastWrite; }
@@ -1664,6 +1664,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
     }
 
     // ----------------------------------------------- SendfileData Inner Class
+
     /**
      * SendfileData class.
      */


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