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 2008/11/17 15:52:25 UTC
svn commit: r718251 -
/mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
Author: elecharny
Date: Mon Nov 17 06:52:25 2008
New Revision: 718251
URL: http://svn.apache.org/viewvc?rev=718251&view=rev
Log:
Added some comments and javadoc
Modified:
mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
Modified: mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java?rev=718251&r1=718250&r2=718251&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java Mon Nov 17 06:52:25 2008
@@ -390,7 +390,7 @@
try {
// 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 explicitely
+ // have occurred, or if the selector has been explicitly
// woke up
int selected = select();
@@ -400,12 +400,17 @@
nHandles += registerHandles();
if (selected > 0) {
+ // We have some connection request, let's process
+ // them here.
processHandles(selectedHandles());
}
// check to see if any cancellation request has been made.
nHandles -= unregisterHandles();
+ // Now, if the number of registred handles is 0, we can
+ // quit the loop: we don't have any socket listening
+ // for incoming connection.
if (nHandles == 0) {
synchronized (lock) {
if (registerQueue.isEmpty()
@@ -426,6 +431,7 @@
}
}
+ // Cleanup all the processors, and shutdown the acceptor.
if (selectable && isDisposing()) {
selectable = false;
try {
@@ -487,26 +493,36 @@
*/
private int registerHandles() {
for (;;) {
+ // The register queue contains the list of services to manage
+ // in this acceptor.
AcceptorOperationFuture future = registerQueue.poll();
+
if (future == null) {
return 0;
}
+ // We create a temporary map to store the bound handles,
+ // as we may have to remove them all if there is an exception
+ // during the sockets opening.
Map<SocketAddress, H> newHandles = new HashMap<SocketAddress, H>();
List<SocketAddress> localAddresses = future.getLocalAddresses();
try {
+ // Process all the addresses
for (SocketAddress a : localAddresses) {
H handle = open(a);
newHandles.put(localAddress(handle), handle);
}
+ // Everything went ok, we can now update the map storing
+ // all the bound sockets.
boundHandles.putAll(newHandles);
// and notify.
future.setDone();
return newHandles.size();
} catch (Exception e) {
+ // We store the exception in the future
future.setException(e);
} finally {
// Roll back if failed to bind all addresses.
@@ -518,6 +534,8 @@
ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
+
+ // TODO : add some comment : what is the wakeup() waking up ?
wakeup();
}
}