Author: markt
Date: Fri Sep 17 14:40:05 2010
New Revision: 998153

URL: http://svn.apache.org/viewvc?rev=998153&view=rev
Log:
Code clean-up.
Align BIO and NIO to make Async refactoring easier

Modified:
    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/Http11NioProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=998153&r1=998152&r2=998153&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Fri Sep 
17 14:40:05 2010
@@ -340,10 +340,8 @@ public class Http11NioProtocol extends A
 
         @Override
         public SocketState process(NioChannel socket) {
-            Http11NioProcessor processor = null;
+            Http11NioProcessor processor = connections.remove(socket);
             try {
-                processor = connections.remove(socket);
-                
                 if (processor == null) {
                     processor = recycledProcessors.poll();
                 }
@@ -351,16 +349,17 @@ public class Http11NioProtocol extends A
                     processor = createProcessor();
                 }
 
-                if (proto.endpoint.isSSLEnabled() && (proto.sslImplementation 
!= null)) {
-                    if (socket instanceof SecureNioChannel) {
-                        SecureNioChannel ch = (SecureNioChannel)socket;
-                        
processor.setSslSupport(proto.sslImplementation.getSSLSupport(ch.getSslEngine().getSession()));
-                    }else processor.setSslSupport(null);
+                if (proto.isSSLEnabled() &&
+                        (proto.sslImplementation != null)
+                        && (socket instanceof SecureNioChannel)) {
+                    SecureNioChannel ch = (SecureNioChannel)socket;
+                    processor.setSslSupport(
+                            proto.sslImplementation.getSSLSupport(
+                                    ch.getSslEngine().getSession()));
                 } else {
                     processor.setSslSupport(null);
                 }
 
-
                 SocketState state = processor.process(socket);
                 if (state == SocketState.LONG) {
                     // In the middle of processing a request/response. Keep the
@@ -389,14 +388,12 @@ public class Http11NioProtocol extends A
 
             } catch (java.net.SocketException e) {
                 // SocketExceptions are normal
-                Http11NioProtocol.log.debug
-                    (sm.getString
-                     ("http11protocol.proto.socketexception.debug"), e);
+                log.debug(sm.getString(
+                        "http11protocol.proto.socketexception.debug"), e);
             } catch (java.io.IOException e) {
                 // IOExceptions are normal
-                Http11NioProtocol.log.debug
-                    (sm.getString
-                     ("http11protocol.proto.ioexception.debug"), e);
+                log.debug(sm.getString(
+                        "http11protocol.proto.ioexception.debug"), e);
             }
             // Future developers: if you discover any other
             // rare-but-nonfatal exceptions, catch them here, and log as
@@ -405,8 +402,7 @@ public class Http11NioProtocol extends A
                 // any other exception or error is odd. Here we log it
                 // with "ERROR" level, so it will show up even on
                 // less-than-verbose logs.
-                Http11NioProtocol.log.error
-                    (sm.getString("http11protocol.proto.error"), e);
+                log.error(sm.getString("http11protocol.proto.error"), e);
             }
             recycledProcessors.offer(processor);
             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=998153&r1=998152&r2=998153&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Fri Sep 17 
14:40:05 2010
@@ -237,7 +237,6 @@ public class Http11Protocol extends Abst
         @Override
         public SocketState process(SocketWrapper<Socket> socket, SocketStatus 
status) {
             Http11Processor processor = connections.remove(socket);
-            boolean recycle = true;
             try {
                 if (processor == null) {
                     processor = recycledProcessors.poll();
@@ -247,8 +246,9 @@ public class Http11Protocol extends Abst
                 }
 
                 if (proto.isSSLEnabled() && (proto.sslImplementation != null)) 
{
-                    processor.setSSLSupport
-                        
(proto.sslImplementation.getSSLSupport(socket.getSocket()));
+                    processor.setSSLSupport(
+                            proto.sslImplementation.getSSLSupport(
+                                    socket.getSocket()));
                 } else {
                     processor.setSSLSupport(null);
                 }
@@ -257,22 +257,20 @@ public class Http11Protocol extends Abst
                 if (state == SocketState.LONG) {
                     connections.put(socket, processor);
                     socket.setAsync(true);
-                    recycle = false;
                 } else {
                     connections.remove(socket);
                     socket.setAsync(false);
+                    recycledProcessors.offer(processor);
                 }
                 return state;
             } catch(java.net.SocketException e) {
                 // SocketExceptions are normal
-                Http11Protocol.log.debug
-                    (sm.getString
-                     ("http11protocol.proto.socketexception.debug"), e);
+                log.debug(sm.getString(
+                        "http11protocol.proto.socketexception.debug"), e);
             } catch (java.io.IOException e) {
                 // IOExceptions are normal
-                Http11Protocol.log.debug
-                    (sm.getString
-                     ("http11protocol.proto.ioexception.debug"), e);
+                log.debug(sm.getString(
+                        "http11protocol.proto.ioexception.debug"), e);
             }
             // Future developers: if you discover any other
             // rare-but-nonfatal exceptions, catch them here, and log as
@@ -281,16 +279,9 @@ public class Http11Protocol extends Abst
                 // any other exception or error is odd. Here we log it
                 // with "ERROR" level, so it will show up even on
                 // less-than-verbose logs.
-                Http11Protocol.log.error
-                    (sm.getString("http11protocol.proto.error"), e);
-            } finally {
-                //       if(proto.adapter != null) proto.adapter.recycle();
-                //                processor.recycle();
-
-                if (recycle) {
-                    recycledProcessors.offer(processor);
-                }
+                log.error(sm.getString("http11protocol.proto.error"), e);
             }
+            recycledProcessors.offer(processor);
             return SocketState.CLOSED;
         }
         



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

Reply via email to