tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1478596 - /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
Date Thu, 02 May 2013 22:52:37 GMT
Author: markt
Date: Thu May  2 22:52:36 2013
New Revision: 1478596

URL: http://svn.apache.org/r1478596
Log:
A little more refactoring to make pulling code up easier

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1478596&r1=1478595&r2=1478596&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Thu May  2 22:52:36
2013
@@ -189,7 +189,7 @@ public class Http11NioProcessor extends 
                     request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
                 }
             } catch (IllegalStateException x) {
-                registerForEvent(SelectionKey.OP_WRITE);
+                registerForEvent(false, true);
             }
         } else if (status == SocketStatus.OPEN_READ) {
             try {
@@ -203,7 +203,7 @@ public class Http11NioProcessor extends 
                     request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
                 }
             } catch (IllegalStateException x) {
-                registerForEvent(SelectionKey.OP_READ);
+                registerForEvent(false, true);
             }
         }
 
@@ -229,7 +229,7 @@ public class Http11NioProcessor extends 
     protected boolean registerForWrite() {
         // Register for write if we have more data to write
         if (outputBuffer.hasDataToWrite()) {
-            registerForEvent(SelectionKey.OP_WRITE);
+            registerForEvent(false, true);
             return true;
         } else {
             return false;
@@ -237,12 +237,18 @@ public class Http11NioProcessor extends 
     }
 
 
-    protected void registerForEvent(int event) {
+    protected void registerForEvent(boolean read, boolean write) {
         final NioEndpoint.KeyAttachment attach =
                 (NioEndpoint.KeyAttachment)socket.getSocket().getAttachment(
                         false);
-        if (attach != null) {
-            attach.interestOps(attach.interestOps() | event);
+        if (attach == null) {
+            return;
+        }
+        if (read) {
+            attach.interestOps(attach.interestOps() | SelectionKey.OP_READ);
+        }
+        if (write) {
+            attach.interestOps(attach.interestOps() | SelectionKey.OP_WRITE);
         }
     }
 



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


Mime
View raw message