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/05/03 00:52:37 UTC

svn commit: r1478596 - /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

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


Re: svn commit: r1478596 - /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Posted by Mark Thomas <ma...@apache.org>.
On 07/05/2013 07:19, Konstantin Kolinko wrote:
> 2013/5/3  <ma...@apache.org>:
>> 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

>> @@ -203,7 +203,7 @@ public class Http11NioProcessor extends
>>                      request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
>>                  }
>>              } catch (IllegalStateException x) {
>> -                registerForEvent(SelectionKey.OP_READ);
>> +                registerForEvent(false, true);
> 
> The above should be "(true, false)", unless this change was intended.

Fixed.

Thanks.

Mark


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


Re: svn commit: r1478596 - /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/5/3  <ma...@apache.org>:
> 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);

The above should be "(true, false)", unless this change was intended.

>              }
>          }
>
> @@ -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
>

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