From jboss-remoting-commits at lists.jboss.org Wed Feb 23 17:02:16 2011 Content-Type: multipart/mixed; boundary="===============0799333822043396836==" MIME-Version: 1.0 From: jboss-remoting-commits at lists.jboss.org To: jboss-remoting-commits at lists.jboss.org Subject: [jboss-remoting-commits] JBoss Remoting SVN: r6248 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket. Date: Wed, 23 Feb 2011 17:02:16 -0500 Message-ID: <201102232202.p1NM2G43008306@svn01.web.mwc.hst.phx2.redhat.com> --===============0799333822043396836== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ron.sigal(a)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/Bi= socketServerInvoker.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/biso= cket/BisocketServerInvoker.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/B= isocketServerInvoker.java 2011-02-11 21:20:52 UTC (rev 6247) +++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/B= isocketServerInvoker.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 Ron Sigal @@ -1092,6 +1094,7 @@ { private ServerSocket secondaryServerSocket; boolean running =3D true; + Semaphore maxThreads =3D new Semaphore(maxPoolSize); = SecondaryServerSocketThread(ServerSocket secondaryServerSocket) thro= ws 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 soc= ket: " + socket); try { + socket.setSoTimeout(DEFAULT_TIMEOUT_PERIOD); DataInputStream dis =3D new DataInputStream(socket.getIn= putStream()); int action =3D dis.read(); String listenerId =3D dis.readUTF(); @@ -1200,6 +1217,7 @@ finally { if (log.isTraceEnabled()) log.trace(this + " processed s= ocket: " + socket); + maxThreads.release(); } } }.start(); --===============0799333822043396836==--