tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1144354 - in /tomcat/trunk/java/org/apache/coyote/http11: Http11AprProtocol.java Http11NioProtocol.java Http11Protocol.java
Date Fri, 08 Jul 2011 15:10:01 GMT
Author: markt
Date: Fri Jul  8 15:10:01 2011
New Revision: 1144354

URL: http://svn.apache.org/viewvc?rev=1144354&view=rev
Log:
More protocol alignment (with an eye to aligning with AJP)

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1144354&r1=1144353&r2=1144354&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Fri Jul  8 15:10:01
2011
@@ -210,7 +210,27 @@ public class Http11AprProtocol extends A
         public void recycle() {
             recycledProcessors.clear();
         }
-        
+
+        /**
+         * Expected to be used by the handler once the processor is no longer
+         * required.
+         * 
+         * @param socket
+         * @param processor
+         * @param isSocketClosing   Not used in HTTP
+         * @param addToPoller
+         */
+        public void release(SocketWrapper<Long> socket,
+                Http11AprProcessor processor, boolean isSocketClosing,
+                boolean addToPoller) {
+            processor.recycle();
+            recycledProcessors.offer(processor);
+            if (addToPoller) {
+                ((AprEndpoint)proto.endpoint).getPoller().add(
+                        socket.getSocket().longValue());
+            }
+        }
+
         @Override
         public SocketState process(SocketWrapper<Long> socket,
                 SocketStatus status) {
@@ -257,14 +277,10 @@ public class Http11AprProtocol extends A
                 } else if (state == SocketState.OPEN){
                     // In keep-alive but between requests. OK to recycle
                     // processor. Continue to poll for the next request.
-                    processor.recycle();
-                    recycledProcessors.offer(processor);
-                    ((AprEndpoint)proto.endpoint).getPoller().add(
-                            socket.getSocket().longValue());
+                    release(socket, processor, false, true);
                 } else {
                     // Connection closed. OK to recycle the processor.
-                    processor.recycle();
-                    recycledProcessors.offer(processor);
+                    release(socket, processor, true, false);
                 }
                 return state;
             } catch (java.net.SocketException e) {
@@ -287,11 +303,11 @@ public class Http11AprProtocol extends A
                 Http11AprProtocol.log.error(
                         sm.getString("http11protocol.proto.error"), e);
             }
-            processor.recycle();
-            recycledProcessors.offer(processor);
+            release(socket, processor, true, false);
             return SocketState.CLOSED;
         }
 
+        @SuppressWarnings("unused")
         private void initSsl(SocketWrapper<Long> socket,
                 Http11AprProcessor processor) {
             // NOOP for APR

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1144354&r1=1144353&r2=1144354&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Fri Jul  8 15:10:01
2011
@@ -187,6 +187,10 @@ public class Http11NioProtocol extends A
             recycledProcessors.clear();
         }
         
+        /**
+         * Expected to be used by the Poller to release resources on socket
+         * close, errors etc.
+         */
         @Override
         public void release(SocketChannel socket) {
             if (log.isDebugEnabled()) 
@@ -209,8 +213,8 @@ public class Http11NioProtocol extends A
         }
         
         /**
-         * Use this only if the processor is not available, otherwise use
-         * {@link #release(SocketWrapper, Http11NioProcessor)}.
+         * Expected to be used by the Poller to release resources on socket
+         * close, errors etc.
          */
         @Override
         public void release(SocketWrapper<NioChannel> socket) {
@@ -222,11 +226,23 @@ public class Http11NioProtocol extends A
         }
 
 
+        /**
+         * Expected to be used by the handler once the processor is no longer
+         * required.
+         * 
+         * @param socket
+         * @param processor
+         * @param isSocketClosing   Not used in HTTP
+         * @param addToPoller
+         */
         public void release(SocketWrapper<NioChannel> socket,
-                Http11NioProcessor processor) {
-            connections.remove(socket);
+                Http11NioProcessor processor, boolean isSocketClosing,
+                boolean addToPoller) {
             processor.recycle();
             recycledProcessors.offer(processor);
+            if (addToPoller) {
+                socket.getSocket().getPoller().add(socket.getSocket());
+            }
         }
 
 
@@ -283,11 +299,10 @@ public class Http11NioProtocol extends A
                 } else if (state == SocketState.OPEN){
                     // In keep-alive but between requests. OK to recycle
                     // processor. Continue to poll for the next request.
-                    release(socket, processor);
-                    socket.getSocket().getPoller().add(socket.getSocket());
+                    release(socket, processor, false, true);
                 } else {
                     // Connection closed. OK to recycle the processor.
-                    release(socket, processor);
+                    release(socket, processor, true, false);
                 }
                 return state;
             } catch (java.net.SocketException e) {
@@ -309,7 +324,7 @@ public class Http11NioProtocol extends A
                 // less-than-verbose logs.
                 log.error(sm.getString("http11protocol.proto.error"), e);
             }
-            release(socket, processor);
+            release(socket, processor, true, false);
             return SocketState.CLOSED;
         }
 

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1144354&r1=1144353&r2=1144354&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Fri Jul  8 15:10:01 2011
@@ -135,6 +135,22 @@ public class Http11Protocol extends Abst
             recycledProcessors.clear();
         }
 
+        /**
+         * Expected to be used by the handler once the processor is no longer
+         * required.
+         * 
+         * @param socket            Not used in BIO
+         * @param processor
+         * @param isSocketClosing   Not used in HTTP
+         * @param addToPoller       Not used in BIO
+         */
+        public void release(SocketWrapper<Socket> socket,
+                Http11Processor processor, boolean isSocketClosing,
+                boolean addToPoller) {
+            processor.recycle();
+            recycledProcessors.offer(processor);
+        }
+
         @Override
         public SocketState process(SocketWrapper<Socket> socket,
                 SocketStatus status) {
@@ -174,12 +190,10 @@ public class Http11Protocol extends Abst
                 } else if (state == SocketState.OPEN){
                     // In keep-alive but between requests. OK to recycle
                     // processor. Continue to poll for the next request.
-                    processor.recycle();
-                    recycledProcessors.offer(processor);
+                    release(socket, processor, false, true);
                 } else {
                     // Connection closed. OK to recycle the processor.
-                    processor.recycle();
-                    recycledProcessors.offer(processor);
+                    release(socket, processor, true, false);
                 }
                 return state;
             } catch(java.net.SocketException e) {
@@ -201,8 +215,7 @@ public class Http11Protocol extends Abst
                 // less-than-verbose logs.
                 log.error(sm.getString("http11protocol.proto.error"), e);
             }
-            processor.recycle();
-            recycledProcessors.offer(processor);
+            release(socket, processor, true, false);
             return SocketState.CLOSED;
         }
         



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


Mime
View raw message