tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1390717 - /tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java
Date Wed, 26 Sep 2012 20:31:12 GMT
Author: markt
Date: Wed Sep 26 20:31:11 2012
New Revision: 1390717

URL: http://svn.apache.org/viewvc?rev=1390717&view=rev
Log:
No need to create runnable and wake up the selector if it isn't going to do anything.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java?rev=1390717&r1=1390716&r2=1390717&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java Wed Sep 26 20:31:11
2012
@@ -244,14 +244,15 @@ public class NioBlockingSelector {
         }
 
         public void add(final KeyAttachment key, final int ops, final KeyReference ref) {
+            if ( key == null ) return;
+            NioChannel nch = key.getChannel();
+            if ( nch == null ) return;
+            final SocketChannel ch = nch.getIOChannel();
+            if ( ch == null ) return;
+
             Runnable r = new Runnable() {
                 @Override
                 public void run() {
-                    if ( key == null ) return;
-                    NioChannel nch = key.getChannel();
-                    if ( nch == null ) return;
-                    SocketChannel ch = nch.getIOChannel();
-                    if ( ch == null ) return;
                     SelectionKey sk = ch.keyFor(selector);
                     try {
                         if (sk == null) {
@@ -274,14 +275,15 @@ public class NioBlockingSelector {
         }
 
         public void remove(final KeyAttachment key, final int ops) {
+            if ( key == null ) return;
+            NioChannel nch = key.getChannel();
+            if ( nch == null ) return;
+            final SocketChannel ch = nch.getIOChannel();
+            if ( ch == null ) return;
+
             Runnable r = new Runnable() {
                 @Override
                 public void run() {
-                    if ( key == null ) return;
-                    NioChannel nch = key.getChannel();
-                    if ( nch == null ) return;
-                    SocketChannel ch = nch.getIOChannel();
-                    if ( ch == null ) return;
                     SelectionKey sk = ch.keyFor(selector);
                     try {
                         if (sk == null) {



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


Mime
View raw message