Repository: mina
Updated Branches:
  refs/heads/2.0 04607fa39 -> dbe15f485


improves the ulimit exception thrown by accept() by looking for the
message "Too many files open" thereby preventing accidental capture of
other valid exceptions.

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

Branch: refs/heads/2.0
Commit: dbe15f485bff93e663fa8b4774e13cc44afba9cf
Parents: 04607fa
Author: jvalliere <jon.valli...@emoten.com>
Authored: Sat Mar 3 11:42:11 2018 -0500
Committer: jvalliere <jon.valli...@emoten.com>
Committed: Sat Mar 3 11:42:11 2018 -0500

----------------------------------------------------------------------
 .../transport/socket/nio/NioSocketAcceptor.java | 24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/dbe15f48/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
----------------------------------------------------------------------
diff --git 
a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
 
b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
index 101b1a8..939f58a 100644
--- 
a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
+++ 
b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioSocketAcceptor.java
@@ -199,16 +199,20 @@ implements SocketAcceptor {
 
             return new NioSocketSession(this, processor, ch);
         } catch (Throwable t) {
-            LOGGER.error("Error Calling Accept on Socket - Sleeping Acceptor 
Thread. Check the ulimit parameter", t);
-            try {
-                // Sleep 50 ms, so that the select does not spin like crazy 
doing nothing but eating CPU
-                // This is typically what will happen if we don't have any 
more File handle on the server
-                // Check the ulimit parameter
-                // NOTE : this is a workaround, there is no way we can handle 
this exception in any smarter way...
-                Thread.sleep(50L);
-            } catch (InterruptedException ie) {
-                // Nothing to do
-            }
+               if(t.getMessage().equals("Too many open files")) {
+                   LOGGER.error("Error Calling Accept on Socket - Sleeping 
Acceptor Thread. Check the ulimit parameter", t);
+                   try {
+                       // Sleep 50 ms, so that the select does not spin like 
crazy doing nothing but eating CPU
+                       // This is typically what will happen if we don't have 
any more File handle on the server
+                       // Check the ulimit parameter
+                       // NOTE : this is a workaround, there is no way we can 
handle this exception in any smarter way...
+                       Thread.sleep(50L);
+                   } catch (InterruptedException ie) {
+                       // Nothing to do
+                   }
+               } else {
+                       throw t;
+               }
 
             // No session when we have met an exception
             return null;

Reply via email to