You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2016/08/11 15:28:17 UTC

[07/10] mina git commit: o Process the new handle before doing a select() o Removed the ThreadSleep() at startup : we process the handle first, so we don't need to wait with a random value.

o Process the new handle before doing a select()
o Removed the ThreadSleep() at startup : we process the handle first, so
we don't need to wait with a random value.

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/d2aeee7b
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/d2aeee7b
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/d2aeee7b

Branch: refs/heads/2.0
Commit: d2aeee7bbe8a342bfe196bcebdda74ba69e62e7a
Parents: ebd9a5a
Author: Emmanuel L�charny <el...@symas.com>
Authored: Thu Aug 11 16:47:22 2016 +0200
Committer: Emmanuel L�charny <el...@symas.com>
Committed: Thu Aug 11 16:47:22 2016 +0200

----------------------------------------------------------------------
 .../core/polling/AbstractPollingIoAcceptor.java     | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/d2aeee7b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
index 5c862fb..f9fad07 100644
--- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
+++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
@@ -356,8 +356,6 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>
         try {
             lock.acquire();
 
-            // Wait a bit to give a chance to the Acceptor thread to do the select()
-            Thread.sleep(10);
             wakeup();
         } finally {
             lock.release();
@@ -447,17 +445,20 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>
 
             while (selectable) {
                 try {
+                    // Process the bound sockets to this acceptor.
+                    // this actually sets the selector to OP_ACCEPT,
+                    // and binds to the port on which this class will
+                    // listen on. We do that before the select because 
+                    // the registerQueue containing the new handler is
+                    // already updated at this point.
+                    nHandles += registerHandles();
+
                     // Detect if we have some keys ready to be processed
                     // The select() will be woke up if some new connection
                     // have occurred, or if the selector has been explicitly
                     // woke up
                     int selected = select();
 
-                    // this actually sets the selector to OP_ACCEPT,
-                    // and binds to the port on which this class will
-                    // listen on
-                    nHandles += registerHandles();
-
                     // Now, if the number of registred handles is 0, we can
                     // quit the loop: we don't have any socket listening
                     // for incoming connection.
@@ -592,6 +593,7 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>
 
                 // and notify.
                 future.setDone();
+                
                 return newHandles.size();
             } catch (Exception e) {
                 // We store the exception in the future