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 2013/02/17 21:36:24 UTC

svn commit: r1447074 - in /tomcat/trunk/java/org/apache/tomcat/jni/socket: AprSocket.java AprSocketContext.java

Author: markt
Date: Sun Feb 17 20:36:24 2013
New Revision: 1447074

URL: http://svn.apache.org/r1447074
Log:
UCDetector
 - use final
 - reduce visibility
 - remove unused code

Modified:
    tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java
    tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java

Modified: tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java?rev=1447074&r1=1447073&r2=1447074&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java Sun Feb 17 20:36:24 2013
@@ -59,33 +59,33 @@ public class AprSocket implements Runnab
     private static final Logger log =
             Logger.getLogger("org.apache.tomcat.jni.socket.AprSocket");
 
-    static final byte[][] NO_CERTS = new byte[0][];
+    private static final byte[][] NO_CERTS = new byte[0][];
 
-    static int CONNECTING = 1;
-    static int CONNECTED = 0x2;
+    final static int CONNECTING = 0x1;
+    final static int CONNECTED = 0x2;
 
     // Current ( real ) poll status
-    static int POLLIN_ACTIVE = 0x4;
-    static int POLLOUT_ACTIVE = 0x8;
+    final static int POLLIN_ACTIVE = 0x4;
+    final static int POLLOUT_ACTIVE = 0x8;
 
-    static int POLL = 0x10;
+    final static int POLL = 0x10;
 
-    static int SSL_ATTACHED = 0x40;
+    final static int SSL_ATTACHED = 0x40;
 
     // Requested poll status. Set by read/write when needed.
     // Cleared when polled
-    static int POLLIN = 0x80;
-    static int POLLOUT = 0x100;
+    final static int POLLIN = 0x80;
+    final static int POLLOUT = 0x100;
 
-    static int ACCEPTED = 0x200;
-    static int ERROR = 0x400;
-    static int CLOSED = 0x800;
+    final static int ACCEPTED = 0x200;
+    final static int ERROR = 0x400;
+    final static int CLOSED = 0x800;
 
-    static int READING = 0x1000;
-    static int WRITING = 0x2000;
+    final static int READING = 0x1000;
+    final static int WRITING = 0x2000;
 
     // Not null
-    private AprSocketContext context;
+    private final AprSocketContext context;
 
     // only one - to save per/socket memory - context has similar callbacks.
     BlockingPollHandler handler;

Modified: tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java?rev=1447074&r1=1447073&r2=1447074&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java Sun Feb 17 20:36:24 2013
@@ -76,20 +76,12 @@ public class AprSocketContext {
         public HostInfo getHostInfo(String name, int port, boolean ssl);
     }
 
-    /**
-     * Reads/writes of this size or lower are using Get/SetByteArrayRegion.
-     * Larger reads use Get/ReelaseByteArrayElements.
-     * Larger writes use malloc/free + GetByteArrayRagion.
-     */
-    static final int TCN_BUFFER_SZ = 8192;
-
-    static Logger log = Logger.getLogger("AprSocketCtx");
+    private static final Logger log = Logger.getLogger("AprSocketCtx");
 
     // If interrupt() or thread-safe poll update are not supported - the
     // poll updates will happen after the poll() timeout.
     // The poll timeout with interrupt/thread safe updates can be much higher/
-    static int FALLBACK_POLL_TIME = 2000;
-    static int MAX_POLL_SIZE = 60;
+    private static final int FALLBACK_POLL_TIME = 2000;
 
     // It seems to send the ticket, get server helo / ChangeCipherSpec, but than
     // SSL3_GET_RECORD:decryption failed or bad record mac in s3_pkt.c:480:
@@ -97,29 +89,26 @@ public class AprSocketContext {
     // ( this can save a roundtrip and CPU on TLS handshake )
     boolean USE_TICKETS = false;
 
-    boolean useFinalizer = true;
+    private final AprSocket END = new AprSocket(this);
 
-    final AprSocket END = new AprSocket(this);
+    private final static AtomicInteger contextNumber = new AtomicInteger();
+    private int contextId;
 
-    static AtomicInteger contextNumber = new AtomicInteger();
-    int contextId;
-
-    AtomicInteger threadNumber = new AtomicInteger();
+    private final AtomicInteger threadNumber = new AtomicInteger();
 
     /**
      * For now - single acceptor thread per connector.
      */
-    AcceptorThread acceptor;
-    AcceptorDispatchThread acceptorDispatch;
+    private AcceptorThread acceptor;
+    private AcceptorDispatchThread acceptorDispatch;
 
     // APR/JNI is thread safe
-    boolean threadSafe = true;
+    private boolean threadSafe = true;
 
     /**
      * Pollers.
      */
-    List<AprPoller> pollers = new ArrayList<>();
-    static int pollerCnt = 0;
+    private final List<AprPoller> pollers = new ArrayList<>();
 
     // Set on all accepted or connected sockets.
     // TODO: add the other properties
@@ -131,9 +120,10 @@ public class AprSocketContext {
 
     // onSocket() will be called in accept thread.
     // If false: use executor ( but that may choke the acceptor thread )
-    protected boolean nonBlockingAccept = false;
+    private boolean nonBlockingAccept = false;
 
-    BlockingQueue<AprSocket> acceptedQueue = new LinkedBlockingQueue<>();
+    private final BlockingQueue<AprSocket> acceptedQueue =
+    		new LinkedBlockingQueue<>();
 
     /**
      * Root APR memory pool.
@@ -148,64 +138,62 @@ public class AprSocketContext {
     TlsCertVerifier tlsCertVerifier;
 
     //
-    int connectTimeout =  20000;
-    int defaultTimeout = 100000;
-
-    int keepAliveTimeout = 20000;
+    final int connectTimeout =  20000;
+    final int defaultTimeout = 100000;
+    // TODO: Use this
+    final int keepAliveTimeout = 20000;
 
-    AtomicInteger open = new AtomicInteger();
+    final AtomicInteger open = new AtomicInteger();
 
     /**
      * Poll interval, in microseconds. If the platform doesn't support
      * poll interrupt - it'll take this time to stop the poller.
      *
      */
-    protected int pollTime = 5 * 1000000;
+    private int pollTime = 5 * 1000000;
 
-    HostInfoLoader hostInfoLoader;
+    private HostInfoLoader hostInfoLoader;
 
-    RawDataHandler rawDataHandler = null;
+    final RawDataHandler rawDataHandler = null;
 
     // TODO: do we need this here ?
-    protected Map<String, HostInfo> hosts = new HashMap<>();
-
-    String[] enabledCiphers;
+    private final Map<String, HostInfo> hosts = new HashMap<>();
 
-    String certFile;
-    String keyFile;
+    private String certFile;
+    private String keyFile;
 
-    byte[] spdyNPN;
+    private byte[] spdyNPN;
 
-    byte[] ticketKey;
+    private byte[] ticketKey;
 
     // For resolving DNS ( i.e. connect ), callbacks
     private ExecutorService threadPool;
 
     // Separate executor for connect/handshakes
-    ExecutorService connectExecutor;
+    final ExecutorService connectExecutor;
 
-    boolean debugSSL = false;
-    boolean debugPoll = false;
+    final boolean debugSSL = false;
+    private boolean debugPoll = false;
 
-    protected boolean deferAccept = false;
+    private boolean deferAccept = false;
 
-    protected int backlog = 100;
+    private int backlog = 100;
 
-    protected boolean useSendfile;
+    private boolean useSendfile;
 
-    int sslProtocol = SSL.SSL_PROTOCOL_TLSV1 | SSL.SSL_PROTOCOL_SSLV3;
+    private int sslProtocol = SSL.SSL_PROTOCOL_TLSV1 | SSL.SSL_PROTOCOL_SSLV3;
 
     /**
      * Max time spent in a callback ( will be longer for blocking )
      */
-    AtomicLong maxHandlerTime = new AtomicLong();
-    AtomicLong totalHandlerTime = new AtomicLong();
-    AtomicLong handlerCount = new AtomicLong();
+    final AtomicLong maxHandlerTime = new AtomicLong();
+    final AtomicLong totalHandlerTime = new AtomicLong();
+    final AtomicLong handlerCount = new AtomicLong();
 
     /**
      * Total connections handled ( accepted or connected ).
      */
-    AtomicInteger connectionsCount = new AtomicInteger();
+    private final AtomicInteger connectionsCount = new AtomicInteger();
 
 
     public AprSocketContext() {
@@ -225,12 +213,12 @@ public class AprSocketContext {
     /**
      * Poller thread count.
      */
-    protected int pollerThreadCount = 4;
+    private int pollerThreadCount = 4;
     public void setPollerThreadCount(int pollerThreadCount) { this.pollerThreadCount = pollerThreadCount; }
     public int getPollerThreadCount() { return pollerThreadCount; }
 
     // to test the limits - default should be lower
-    int maxConnections = 64 * 1024;
+    private int maxConnections = 64 * 1024;
     public void setMaxconnections(int maxCon) {
         this.maxConnections = maxCon;
     }
@@ -330,10 +318,6 @@ public class AprSocketContext {
         tlsCertVerifier = verifier;
     }
 
-    public void setEnabledCiphers(String[] enabled) {
-        enabledCiphers = enabled;
-    }
-
     // TODO: should have a separate method for switching to tls later.
     /**
      * Set certificate, will also enable TLS mode.
@@ -349,7 +333,7 @@ public class AprSocketContext {
     /**
      * SSL cipher suite.
      */
-    protected String SSLCipherSuite = "ALL";
+    private String SSLCipherSuite = "ALL";
     public String getSSLCipherSuite() { return SSLCipherSuite; }
     public void setSSLCipherSuite(String SSLCipherSuite) { this.SSLCipherSuite = SSLCipherSuite; }
 
@@ -590,7 +574,7 @@ public class AprSocketContext {
         }
     }
 
-    static IOException noApr;
+    private static IOException noApr;
     static {
 
         try {
@@ -741,14 +725,12 @@ public class AprSocketContext {
         // Defaults to NO-OP. Parameter is used by sub-classes.
     }
 
-    class AcceptorThread extends Thread {
-        int port;
-        long serverSockPool = 0;
-        long serverSock = 0;
-
-        final String addressStr = null;
+    private class AcceptorThread extends Thread {
+        private final int port;
+        private long serverSockPool = 0;
+        private long serverSock = 0;
 
-        long inetAddress;
+        private long inetAddress;
 
         AcceptorThread(int port) {
             this.port = port;
@@ -761,8 +743,8 @@ public class AprSocketContext {
                 serverSockPool = Pool.create(getRootPool());
 
                 int family = Socket.APR_INET;
-                inetAddress = Address.info(addressStr, family,
-                        port, 0, serverSockPool);
+                inetAddress =
+                		Address.info(null, family, port, 0, serverSockPool);
 
                 // Create the APR server socket
                 serverSock = Socket.create(family,
@@ -851,7 +833,7 @@ public class AprSocketContext {
         }
     }
 
-    class AcceptorDispatchThread extends Thread {
+    private class AcceptorDispatchThread extends Thread {
 
         AcceptorDispatchThread() {
             setDaemon(true);
@@ -912,7 +894,7 @@ public class AprSocketContext {
 
     // Removed the 'thread safe' updates for now, to simplify the code
     // last test shows a small improvement, can switch later.
-    static boolean sizeLogged = false;
+    private static boolean sizeLogged = false;
 
     protected long allocatePoller(int size, long pool) {
         int flag = threadSafe ? Poll.APR_POLLSET_THREADSAFE: 0;
@@ -943,31 +925,30 @@ public class AprSocketContext {
 
     class AprPoller extends Thread {
 
-        public int id;
-        public int size;
-        protected long serverPollset = 0;
-        protected long pool = 0;
-        protected long[] desc;
-
-        long lastPoll;
-        long lastPollTime;
-        long lastCallbackTime;
-        AtomicBoolean inPoll = new AtomicBoolean(false);
+        private int id;
+        private int size;
+        private long serverPollset = 0;
+        private long pool = 0;
+        private long[] desc;
+
+        private long lastPoll;
+        private long lastPollTime;
+        private final AtomicBoolean inPoll = new AtomicBoolean(false);
 
         // Should be replaced with socket data.
         // used only to lookup by socket
-        Map<Long, AprSocket> channels = new HashMap<>();
+        private final Map<Long, AprSocket> channels = new HashMap<>();
 
         // Active + pending, must be < desc.length / 2
         // The channel will also have poller=this when active or pending
         // How many sockets have poller == this
-        protected AtomicInteger keepAliveCount = new AtomicInteger();
+        private final AtomicInteger keepAliveCount = new AtomicInteger();
         // Tracks desc, how many sockets are actively polled
-        protected AtomicInteger polledCount = new AtomicInteger();
+        private final AtomicInteger polledCount = new AtomicInteger();
 
-        protected AtomicInteger pollCount = new AtomicInteger();
+        private final AtomicInteger pollCount = new AtomicInteger();
 
-        private List<AprSocket> updates = new ArrayList<>();
+        private final List<AprSocket> updates = new ArrayList<>();
 
         @Override
         public void run() {
@@ -982,9 +963,6 @@ public class AprSocketContext {
                 try {
                     updates();
 
-
-                    lastCallbackTime = t0 - lastPoll;
-
                     // Pool for the specified interval. Remove signaled sockets
                     synchronized (this) {
                         inPoll.set(true);



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


Re: svn commit: r1447074 - in /tomcat/trunk/java/org/apache/tomcat/jni/socket: AprSocket.java AprSocketContext.java

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/2/18 Mark Thomas <ma...@apache.org>:
> On 17/02/2013 21:48, Konstantin Kolinko wrote:
>> Adding "finals" to apparent constant fields is OK (e.g. those
>> CONNECTING, CONNECTED fields), but generic reducing visibilities here
>> and there seems wrong.
>
> o.a.tomcat.jni.socket is the package added for spdy support. The code is
> still a work in progress. For example:
> - keepAliveTimeout (currently unused)
> - Look at the TODOs
> - hard-coded flags such as USE_TICKETS, nonBlockingAccept, debugPoll
>
> I have no problem reducing visibility as I did. UCDetector raises many
> more issues than I fixed. I left those because I judged that as the code
> was completed those issues would be resolved.
>
>> I think we either have to revert most of this commit and resort to the
>> usual routine of @deprecating and leave current visibilities as is,
>> or change external in tc-native to point to 7.0.x code instead of
>> trunk.
>
> I disagree with both suggestions.
>

OK. Understood.
I did not notice it was a new class. Let's go on then.

(Just for reference - it was added in
http://svn.apache.org/viewvc?view=revision&revision=1299980 )


>> That is just based on our policies. I personally do not use this
>> AprSocket class.
>
> Our policy varies depending on the stability of the code in question.
> This code is a work in progress (much like the WebSocket code) so we can
> change pretty much whatever we like.
>

OK.

>> Other possible worry is that I think that UCDetector cannot detect
>> when something is used from the native side. I wonder whether it
>> proposed to delete the private constructor of o.a.t.jni.Error class,
>> which is not used from Java but is used from native/src/error.c.
>> (It is not a concern for these AprSocket, AprSocketContext classes as
>> they appear to be never mentioned in the native code).
>
> That should be the least of your worries. UCDetector doesn't spot use by
> the digester (hence suggests most getters and setters can be removed)
> nor does it spot use in generated code by Jasper (hence suggests large
> chunks of Jasper code can be removed).
>
> Because of the rather non-standard things we do in Tomcat, UCDetector
> isn't a tool that can be followed blindly. It needs to be used by
> someone with a reasonable understanding of the code and the suggestions
> (particularly those to remove code) need to be checked carefully before
> following them.

Thank you for reminding me.

Best regards,
Konstantin Kolinko

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


Re: svn commit: r1447074 - in /tomcat/trunk/java/org/apache/tomcat/jni/socket: AprSocket.java AprSocketContext.java

Posted by Mark Thomas <ma...@apache.org>.
On 17/02/2013 21:48, Konstantin Kolinko wrote:
> Adding "finals" to apparent constant fields is OK (e.g. those
> CONNECTING, CONNECTED fields), but generic reducing visibilities here
> and there seems wrong.

o.a.tomcat.jni.socket is the package added for spdy support. The code is
still a work in progress. For example:
- keepAliveTimeout (currently unused)
- Look at the TODOs
- hard-coded flags such as USE_TICKETS, nonBlockingAccept, debugPoll

I have no problem reducing visibility as I did. UCDetector raises many
more issues than I fixed. I left those because I judged that as the code
was completed those issues would be resolved.

> I think we either have to revert most of this commit and resort to the
> usual routine of @deprecating and leave current visibilities as is,
> or change external in tc-native to point to 7.0.x code instead of
> trunk.

I disagree with both suggestions.

> That is just based on our policies. I personally do not use this
> AprSocket class.

Our policy varies depending on the stability of the code in question.
This code is a work in progress (much like the WebSocket code) so we can
change pretty much whatever we like.

> Other possible worry is that I think that UCDetector cannot detect
> when something is used from the native side. I wonder whether it
> proposed to delete the private constructor of o.a.t.jni.Error class,
> which is not used from Java but is used from native/src/error.c.
> (It is not a concern for these AprSocket, AprSocketContext classes as
> they appear to be never mentioned in the native code).

That should be the least of your worries. UCDetector doesn't spot use by
the digester (hence suggests most getters and setters can be removed)
nor does it spot use in generated code by Jasper (hence suggests large
chunks of Jasper code can be removed).

Because of the rather non-standard things we do in Tomcat, UCDetector
isn't a tool that can be followed blindly. It needs to be used by
someone with a reasonable understanding of the code and the suggestions
(particularly those to remove code) need to be checked carefully before
following them.

Mark


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


Re: svn commit: r1447074 - in /tomcat/trunk/java/org/apache/tomcat/jni/socket: AprSocket.java AprSocketContext.java

Posted by Rainer Jung <ra...@kippdata.de>.
On 17.02.2013 22:48, Konstantin Kolinko wrote:
> 2013/2/18  <ma...@apache.org>:
>> Author: markt
>> Date: Sun Feb 17 20:36:24 2013
>> New Revision: 1447074
>>
>> URL: http://svn.apache.org/r1447074
>> Log:
>> UCDetector
>>  - use final
>>  - reduce visibility
>>  - remove unused code
> 
> Note that because of earlier (today's) Rainer's e-mail what you are
> editing here belongs not to "trunk" but to 1.1.x branch of Tomcat
> native.  See r1447038, r1447045
> 
> Adding "finals" to apparent constant fields is OK (e.g. those
> CONNECTING, CONNECTED fields), but generic reducing visibilities here
> and there seems wrong.
> 
> I think we either have to revert most of this commit and resort to the
> usual routine of @deprecating and leave current visibilities as is,
> or change external in tc-native to point to 7.0.x code instead of
> trunk.
> 
> That is just based on our policies. I personally do not use this
> AprSocket class.
> 
> 
> Other possible worry is that I think that UCDetector cannot detect
> when something is used from the native side. I wonder whether it
> proposed to delete the private constructor of o.a.t.jni.Error class,
> which is not used from Java but is used from native/src/error.c.
> (It is not a concern for these AprSocket, AprSocketContext classes as
> they appear to be never mentioned in the native code).

One more aspect: there was no separate "trunk" version of the tcnative
Java classes. Maintaining two versions didn't work well. That's why we
falled back to linking branches/1.1.x jni classes to TC trunk.

We could of course link 1.1.x to TC 7 and reintroduce the java classes
to tcnative trunk as an external to TC trunk. I must say I doubt that
this works. Most development on tcnative happens in 1.1.x, so IMHO the
Java classes in tcnative 1.1.x seem to be better suited by a more
relaxed version compatibility requirement.

Regards,

Rainer

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


Re: svn commit: r1447074 - in /tomcat/trunk/java/org/apache/tomcat/jni/socket: AprSocket.java AprSocketContext.java

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/2/18  <ma...@apache.org>:
> Author: markt
> Date: Sun Feb 17 20:36:24 2013
> New Revision: 1447074
>
> URL: http://svn.apache.org/r1447074
> Log:
> UCDetector
>  - use final
>  - reduce visibility
>  - remove unused code

Note that because of earlier (today's) Rainer's e-mail what you are
editing here belongs not to "trunk" but to 1.1.x branch of Tomcat
native.  See r1447038, r1447045

Adding "finals" to apparent constant fields is OK (e.g. those
CONNECTING, CONNECTED fields), but generic reducing visibilities here
and there seems wrong.

I think we either have to revert most of this commit and resort to the
usual routine of @deprecating and leave current visibilities as is,
or change external in tc-native to point to 7.0.x code instead of
trunk.

That is just based on our policies. I personally do not use this
AprSocket class.


Other possible worry is that I think that UCDetector cannot detect
when something is used from the native side. I wonder whether it
proposed to delete the private constructor of o.a.t.jni.Error class,
which is not used from Java but is used from native/src/error.c.
(It is not a concern for these AprSocket, AprSocketContext classes as
they appear to be never mentioned in the native code).

Best regards,
Konstantin Kolinko

> Modified:
>     tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java
>     tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java
>
> Modified: tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java?rev=1447074&r1=1447073&r2=1447074&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java (original)
> +++ tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocket.java Sun Feb 17 20:36:24 2013
> @@ -59,33 +59,33 @@ public class AprSocket implements Runnab
>      private static final Logger log =
>              Logger.getLogger("org.apache.tomcat.jni.socket.AprSocket");
>
> -    static final byte[][] NO_CERTS = new byte[0][];
> +    private static final byte[][] NO_CERTS = new byte[0][];
>
> -    static int CONNECTING = 1;
> -    static int CONNECTED = 0x2;
> +    final static int CONNECTING = 0x1;
> +    final static int CONNECTED = 0x2;
>
>      // Current ( real ) poll status
> -    static int POLLIN_ACTIVE = 0x4;
> -    static int POLLOUT_ACTIVE = 0x8;
> +    final static int POLLIN_ACTIVE = 0x4;
> +    final static int POLLOUT_ACTIVE = 0x8;
>
> -    static int POLL = 0x10;
> +    final static int POLL = 0x10;
>
> -    static int SSL_ATTACHED = 0x40;
> +    final static int SSL_ATTACHED = 0x40;
>
>      // Requested poll status. Set by read/write when needed.
>      // Cleared when polled
> -    static int POLLIN = 0x80;
> -    static int POLLOUT = 0x100;
> +    final static int POLLIN = 0x80;
> +    final static int POLLOUT = 0x100;
>
> -    static int ACCEPTED = 0x200;
> -    static int ERROR = 0x400;
> -    static int CLOSED = 0x800;
> +    final static int ACCEPTED = 0x200;
> +    final static int ERROR = 0x400;
> +    final static int CLOSED = 0x800;
>
> -    static int READING = 0x1000;
> -    static int WRITING = 0x2000;
> +    final static int READING = 0x1000;
> +    final static int WRITING = 0x2000;
>
>      // Not null
> -    private AprSocketContext context;
> +    private final AprSocketContext context;
>
>      // only one - to save per/socket memory - context has similar callbacks.
>      BlockingPollHandler handler;
>
> Modified: tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java?rev=1447074&r1=1447073&r2=1447074&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java (original)
> +++ tomcat/trunk/java/org/apache/tomcat/jni/socket/AprSocketContext.java Sun Feb 17 20:36:24 2013
> @@ -76,20 +76,12 @@ public class AprSocketContext {
>          public HostInfo getHostInfo(String name, int port, boolean ssl);
>      }
>
> -    /**
> -     * Reads/writes of this size or lower are using Get/SetByteArrayRegion.
> -     * Larger reads use Get/ReelaseByteArrayElements.
> -     * Larger writes use malloc/free + GetByteArrayRagion.
> -     */
> -    static final int TCN_BUFFER_SZ = 8192;
> -
> -    static Logger log = Logger.getLogger("AprSocketCtx");
> +    private static final Logger log = Logger.getLogger("AprSocketCtx");
>
>      // If interrupt() or thread-safe poll update are not supported - the
>      // poll updates will happen after the poll() timeout.
>      // The poll timeout with interrupt/thread safe updates can be much higher/
> -    static int FALLBACK_POLL_TIME = 2000;
> -    static int MAX_POLL_SIZE = 60;
> +    private static final int FALLBACK_POLL_TIME = 2000;
>
>      // It seems to send the ticket, get server helo / ChangeCipherSpec, but than
>      // SSL3_GET_RECORD:decryption failed or bad record mac in s3_pkt.c:480:
> @@ -97,29 +89,26 @@ public class AprSocketContext {
>      // ( this can save a roundtrip and CPU on TLS handshake )
>      boolean USE_TICKETS = false;
>
> -    boolean useFinalizer = true;
> +    private final AprSocket END = new AprSocket(this);
>
> -    final AprSocket END = new AprSocket(this);
> +    private final static AtomicInteger contextNumber = new AtomicInteger();
> +    private int contextId;
>
> -    static AtomicInteger contextNumber = new AtomicInteger();
> -    int contextId;
> -
> -    AtomicInteger threadNumber = new AtomicInteger();
> +    private final AtomicInteger threadNumber = new AtomicInteger();
>
>      /**
>       * For now - single acceptor thread per connector.
>       */
> -    AcceptorThread acceptor;
> -    AcceptorDispatchThread acceptorDispatch;
> +    private AcceptorThread acceptor;
> +    private AcceptorDispatchThread acceptorDispatch;
>
>      // APR/JNI is thread safe
> -    boolean threadSafe = true;
> +    private boolean threadSafe = true;
>
>      /**
>       * Pollers.
>       */
> -    List<AprPoller> pollers = new ArrayList<>();
> -    static int pollerCnt = 0;
> +    private final List<AprPoller> pollers = new ArrayList<>();
>
>      // Set on all accepted or connected sockets.
>      // TODO: add the other properties
> @@ -131,9 +120,10 @@ public class AprSocketContext {
>
>      // onSocket() will be called in accept thread.
>      // If false: use executor ( but that may choke the acceptor thread )
> -    protected boolean nonBlockingAccept = false;
> +    private boolean nonBlockingAccept = false;
>
> -    BlockingQueue<AprSocket> acceptedQueue = new LinkedBlockingQueue<>();
> +    private final BlockingQueue<AprSocket> acceptedQueue =
> +               new LinkedBlockingQueue<>();
>
>      /**
>       * Root APR memory pool.
> @@ -148,64 +138,62 @@ public class AprSocketContext {
>      TlsCertVerifier tlsCertVerifier;
>
>      //
> -    int connectTimeout =  20000;
> -    int defaultTimeout = 100000;
> -
> -    int keepAliveTimeout = 20000;
> +    final int connectTimeout =  20000;
> +    final int defaultTimeout = 100000;
> +    // TODO: Use this
> +    final int keepAliveTimeout = 20000;
>
> -    AtomicInteger open = new AtomicInteger();
> +    final AtomicInteger open = new AtomicInteger();
>
>      /**
>       * Poll interval, in microseconds. If the platform doesn't support
>       * poll interrupt - it'll take this time to stop the poller.
>       *
>       */
> -    protected int pollTime = 5 * 1000000;
> +    private int pollTime = 5 * 1000000;
>
> -    HostInfoLoader hostInfoLoader;
> +    private HostInfoLoader hostInfoLoader;
>
> -    RawDataHandler rawDataHandler = null;
> +    final RawDataHandler rawDataHandler = null;
>
>      // TODO: do we need this here ?
> -    protected Map<String, HostInfo> hosts = new HashMap<>();
> -
> -    String[] enabledCiphers;
> +    private final Map<String, HostInfo> hosts = new HashMap<>();
>
> -    String certFile;
> -    String keyFile;
> +    private String certFile;
> +    private String keyFile;
>
> -    byte[] spdyNPN;
> +    private byte[] spdyNPN;
>
> -    byte[] ticketKey;
> +    private byte[] ticketKey;
>
>      // For resolving DNS ( i.e. connect ), callbacks
>      private ExecutorService threadPool;
>
>      // Separate executor for connect/handshakes
> -    ExecutorService connectExecutor;
> +    final ExecutorService connectExecutor;
>
> -    boolean debugSSL = false;
> -    boolean debugPoll = false;
> +    final boolean debugSSL = false;
> +    private boolean debugPoll = false;
>
> -    protected boolean deferAccept = false;
> +    private boolean deferAccept = false;
>
> -    protected int backlog = 100;
> +    private int backlog = 100;
>
> -    protected boolean useSendfile;
> +    private boolean useSendfile;
>
> -    int sslProtocol = SSL.SSL_PROTOCOL_TLSV1 | SSL.SSL_PROTOCOL_SSLV3;
> +    private int sslProtocol = SSL.SSL_PROTOCOL_TLSV1 | SSL.SSL_PROTOCOL_SSLV3;
>
>      /**
>       * Max time spent in a callback ( will be longer for blocking )
>       */
> -    AtomicLong maxHandlerTime = new AtomicLong();
> -    AtomicLong totalHandlerTime = new AtomicLong();
> -    AtomicLong handlerCount = new AtomicLong();
> +    final AtomicLong maxHandlerTime = new AtomicLong();
> +    final AtomicLong totalHandlerTime = new AtomicLong();
> +    final AtomicLong handlerCount = new AtomicLong();
>
>      /**
>       * Total connections handled ( accepted or connected ).
>       */
> -    AtomicInteger connectionsCount = new AtomicInteger();
> +    private final AtomicInteger connectionsCount = new AtomicInteger();
>
>
>      public AprSocketContext() {
> @@ -225,12 +213,12 @@ public class AprSocketContext {
>      /**
>       * Poller thread count.
>       */
> -    protected int pollerThreadCount = 4;
> +    private int pollerThreadCount = 4;
>      public void setPollerThreadCount(int pollerThreadCount) { this.pollerThreadCount = pollerThreadCount; }
>      public int getPollerThreadCount() { return pollerThreadCount; }
>
>      // to test the limits - default should be lower
> -    int maxConnections = 64 * 1024;
> +    private int maxConnections = 64 * 1024;
>      public void setMaxconnections(int maxCon) {
>          this.maxConnections = maxCon;
>      }
> @@ -330,10 +318,6 @@ public class AprSocketContext {
>          tlsCertVerifier = verifier;
>      }
>
> -    public void setEnabledCiphers(String[] enabled) {
> -        enabledCiphers = enabled;
> -    }
> -
>      // TODO: should have a separate method for switching to tls later.
>      /**
>       * Set certificate, will also enable TLS mode.
> @@ -349,7 +333,7 @@ public class AprSocketContext {
>      /**
>       * SSL cipher suite.
>       */
> -    protected String SSLCipherSuite = "ALL";
> +    private String SSLCipherSuite = "ALL";
>      public String getSSLCipherSuite() { return SSLCipherSuite; }
>      public void setSSLCipherSuite(String SSLCipherSuite) { this.SSLCipherSuite = SSLCipherSuite; }
>
> @@ -590,7 +574,7 @@ public class AprSocketContext {
>          }
>      }
>
> -    static IOException noApr;
> +    private static IOException noApr;
>      static {
>
>          try {
> @@ -741,14 +725,12 @@ public class AprSocketContext {
>          // Defaults to NO-OP. Parameter is used by sub-classes.
>      }
>
> -    class AcceptorThread extends Thread {
> -        int port;
> -        long serverSockPool = 0;
> -        long serverSock = 0;
> -
> -        final String addressStr = null;
> +    private class AcceptorThread extends Thread {
> +        private final int port;
> +        private long serverSockPool = 0;
> +        private long serverSock = 0;
>
> -        long inetAddress;
> +        private long inetAddress;
>
>          AcceptorThread(int port) {
>              this.port = port;
> @@ -761,8 +743,8 @@ public class AprSocketContext {
>                  serverSockPool = Pool.create(getRootPool());
>
>                  int family = Socket.APR_INET;
> -                inetAddress = Address.info(addressStr, family,
> -                        port, 0, serverSockPool);
> +                inetAddress =
> +                               Address.info(null, family, port, 0, serverSockPool);
>
>                  // Create the APR server socket
>                  serverSock = Socket.create(family,
> @@ -851,7 +833,7 @@ public class AprSocketContext {
>          }
>      }
>
> -    class AcceptorDispatchThread extends Thread {
> +    private class AcceptorDispatchThread extends Thread {
>
>          AcceptorDispatchThread() {
>              setDaemon(true);
> @@ -912,7 +894,7 @@ public class AprSocketContext {
>
>      // Removed the 'thread safe' updates for now, to simplify the code
>      // last test shows a small improvement, can switch later.
> -    static boolean sizeLogged = false;
> +    private static boolean sizeLogged = false;
>
>      protected long allocatePoller(int size, long pool) {
>          int flag = threadSafe ? Poll.APR_POLLSET_THREADSAFE: 0;
> @@ -943,31 +925,30 @@ public class AprSocketContext {
>
>      class AprPoller extends Thread {
>
> -        public int id;
> -        public int size;
> -        protected long serverPollset = 0;
> -        protected long pool = 0;
> -        protected long[] desc;
> -
> -        long lastPoll;
> -        long lastPollTime;
> -        long lastCallbackTime;
> -        AtomicBoolean inPoll = new AtomicBoolean(false);
> +        private int id;
> +        private int size;
> +        private long serverPollset = 0;
> +        private long pool = 0;
> +        private long[] desc;
> +
> +        private long lastPoll;
> +        private long lastPollTime;
> +        private final AtomicBoolean inPoll = new AtomicBoolean(false);
>
>          // Should be replaced with socket data.
>          // used only to lookup by socket
> -        Map<Long, AprSocket> channels = new HashMap<>();
> +        private final Map<Long, AprSocket> channels = new HashMap<>();
>
>          // Active + pending, must be < desc.length / 2
>          // The channel will also have poller=this when active or pending
>          // How many sockets have poller == this
> -        protected AtomicInteger keepAliveCount = new AtomicInteger();
> +        private final AtomicInteger keepAliveCount = new AtomicInteger();
>          // Tracks desc, how many sockets are actively polled
> -        protected AtomicInteger polledCount = new AtomicInteger();
> +        private final AtomicInteger polledCount = new AtomicInteger();
>
> -        protected AtomicInteger pollCount = new AtomicInteger();
> +        private final AtomicInteger pollCount = new AtomicInteger();
>
> -        private List<AprSocket> updates = new ArrayList<>();
> +        private final List<AprSocket> updates = new ArrayList<>();
>
>          @Override
>          public void run() {
> @@ -982,9 +963,6 @@ public class AprSocketContext {
>                  try {
>                      updates();
>
> -
> -                    lastCallbackTime = t0 - lastPoll;
> -
>                      // Pool for the specified interval. Remove signaled sockets
>                      synchronized (this) {
>                          inPoll.set(true);
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>

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