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 a472f6a  Pull down APR specific lock structure
a472f6a is described below

commit a472f6af67a7cc03fe42a55cfaa7902933117afd
Author: remm <r...@apache.org>
AuthorDate: Thu Nov 21 11:28:07 2019 +0100

    Pull down APR specific lock structure
    
    They would otherwise be allocated for NIOx but are not used at all.
---
 java/org/apache/tomcat/util/net/AprEndpoint.java   | 21 ++++++++++++++
 .../apache/tomcat/util/net/SocketWrapperBase.java  | 32 +++++++---------------
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java 
b/java/org/apache/tomcat/util/net/AprEndpoint.java
index f34ccf3..10322da 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -32,6 +32,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
 
 import javax.net.ssl.KeyManager;
@@ -2020,9 +2021,21 @@ public class AprEndpoint extends 
AbstractEndpoint<Long,Long> implements SNICallB
         // This field should only be used by Poller#run()
         private int pollerFlags = 0;
 
+        /*
+         * Used if block/non-blocking is set at the socket level. The client is
+         * responsible for the thread-safe use of this field via the locks 
provided.
+         */
+        private volatile boolean blockingStatus = true;
+        private final Lock blockingStatusReadLock;
+        private final WriteLock blockingStatusWriteLock;
+
         public AprSocketWrapper(Long socket, AprEndpoint endpoint) {
             super(socket, endpoint);
 
+            ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+            this.blockingStatusReadLock = lock.readLock();
+            this.blockingStatusWriteLock = lock.writeLock();
+
             // TODO Make the socketWriteBuffer size configurable and align the
             //      SSL and app buffer size settings with NIO & NIO2.
             if (endpoint.isSSLEnabled()) {
@@ -2035,6 +2048,14 @@ public class AprEndpoint extends 
AbstractEndpoint<Long,Long> implements SNICallB
             socketBufferHandler = new SocketBufferHandler(6 * 1500, 6 * 1500, 
true);
         }
 
+        public boolean getBlockingStatus() { return blockingStatus; }
+        public void setBlockingStatus(boolean blockingStatus) {
+            this.blockingStatus = blockingStatus;
+        }
+        public Lock getBlockingStatusReadLock() { return 
blockingStatusReadLock; }
+        public WriteLock getBlockingStatusWriteLock() {
+            return blockingStatusWriteLock;
+        }
 
         @Override
         public int read(boolean block, byte[] b, int off, int len) throws 
IOException {
diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java 
b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
index 1b700cb..e81eb26 100644
--- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java
+++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
@@ -29,9 +29,6 @@ import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -58,6 +55,7 @@ public abstract class SocketWrapperBase<E> {
     private volatile boolean upgraded = false;
     private boolean secure = false;
     private String negotiatedProtocol = null;
+
     /*
      * Following cached for speed / reduced GC
      */
@@ -67,14 +65,8 @@ public abstract class SocketWrapperBase<E> {
     protected String remoteAddr = null;
     protected String remoteHost = null;
     protected int remotePort = -1;
-    /*
-     * Used if block/non-blocking is set at the socket level. The client is
-     * responsible for the thread-safe use of this field via the locks 
provided.
-     */
-    private volatile boolean blockingStatus = true;
-    private final Lock blockingStatusReadLock;
-    private final WriteLock blockingStatusWriteLock;
-    /*
+
+    /**
      * Used to record the first IOException that occurs during non-blocking
      * read/writes that can't be usefully propagated up the stack since there 
is
      * no user code or appropriate container code in the stack to handle it.
@@ -103,19 +95,23 @@ public abstract class SocketWrapperBase<E> {
      */
     protected final WriteBuffer nonBlockingWriteBuffer = new 
WriteBuffer(bufferedWriteSize);
 
+    /*
+     * Asynchronous operations.
+     */
     protected final Semaphore readPending;
     protected volatile OperationState<?> readOperation = null;
     protected final Semaphore writePending;
     protected volatile OperationState<?> writeOperation = null;
 
+    /**
+     * The org.apache.coyote.Processor instance currently associated
+     * with the wrapper.
+     */
     protected Object currentProcessor = null;
 
     public SocketWrapperBase(E socket, AbstractEndpoint<E,?> endpoint) {
         this.socket = socket;
         this.endpoint = endpoint;
-        ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-        this.blockingStatusReadLock = lock.readLock();
-        this.blockingStatusWriteLock = lock.writeLock();
         if (endpoint.getUseAsyncIO() || needSemaphores()) {
             readPending = new Semaphore(1);
             writePending = new Semaphore(1);
@@ -278,14 +274,6 @@ public abstract class SocketWrapperBase<E> {
     }
     protected abstract void populateLocalPort();
 
-    public boolean getBlockingStatus() { return blockingStatus; }
-    public void setBlockingStatus(boolean blockingStatus) {
-        this.blockingStatus = blockingStatus;
-    }
-    public Lock getBlockingStatusReadLock() { return blockingStatusReadLock; }
-    public WriteLock getBlockingStatusWriteLock() {
-        return blockingStatusWriteLock;
-    }
     public SocketBufferHandler getSocketBufferHandler() { return 
socketBufferHandler; }
 
     public boolean hasDataToRead() {


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

Reply via email to