[jboss-remoting-commits] JBoss Remoting SVN: r6248 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Feb 23 17:02:16 EST 2011


Author: ron.sigal at jboss.com
Date: 2011-02-23 17:02:16 -0500 (Wed, 23 Feb 2011)
New Revision: 6248

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1261: (1) restrict the number of threads created; (2) set timeout for Socket.read().


Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java	2011-02-11 21:20:52 UTC (rev 6247)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java	2011-02-23 22:02:16 UTC (rev 6248)
@@ -62,7 +62,9 @@
 import org.jboss.remoting.transport.socket.SocketServerInvoker;
 import org.jboss.remoting.util.SecurityUtility;
 
+import EDU.oswego.cs.dl.util.concurrent.Semaphore;
 
+
 /**
  *
  * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
@@ -1092,6 +1094,7 @@
    {
       private ServerSocket secondaryServerSocket;
       boolean running = true;
+      Semaphore maxThreads = new Semaphore(maxPoolSize);
 
       SecondaryServerSocketThread(ServerSocket secondaryServerSocket) throws IOException
       {
@@ -1142,6 +1145,19 @@
 
       void processSocket(final Socket socket) throws IOException
       {
+         while (true)
+         {
+            try
+            {
+               maxThreads.acquire();
+               break;
+            }
+            catch (InterruptedException e1)
+            {
+               log.trace("unexpected interrupt");
+            }
+         }
+         
          new Thread()
          {
             public void run()
@@ -1150,6 +1166,7 @@
                if (log.isTraceEnabled()) log.trace(this + " processing socket: " + socket);
                try
                {
+                  socket.setSoTimeout(DEFAULT_TIMEOUT_PERIOD);
                   DataInputStream dis = new DataInputStream(socket.getInputStream());
                   int action = dis.read();
                   String listenerId = dis.readUTF();
@@ -1200,6 +1217,7 @@
                finally
                {
                   if (log.isTraceEnabled()) log.trace(this + " processed socket: " + socket);
+                  maxThreads.release();
                }
             }
          }.start();



More information about the jboss-remoting-commits mailing list