[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...

Tom Elrod tom.elrod at jboss.com
Tue Aug 22 23:57:37 EDT 2006


  User: telrod  
  Date: 06/08/22 23:57:37

  Modified:    src/main/org/jboss/remoting/transport/socket  
                        MicroSocketClientInvoker.java ServerThread.java
  Log:
  JBREM-586 - fixed socket client invoker so is back to having bounded connection pool
  
  Revision  Changes    Path
  1.14      +39 -32    JBossRemoting/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MicroSocketClientInvoker.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- MicroSocketClientInvoker.java	12 Aug 2006 03:41:19 -0000	1.13
  +++ MicroSocketClientInvoker.java	23 Aug 2006 03:57:37 -0000	1.14
  @@ -30,7 +30,7 @@
    *
    * @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
    * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
    */
   public class MicroSocketClientInvoker extends RemoteClientInvoker
   {
  @@ -93,7 +93,8 @@
       * for connection to be returned to connection pool before erroring. Default is 30.
       */
      public static final int MAX_RETRIES = 30;
  -   public static long usedPooled = 0;
  +   public long usedPooled = 0;
  +   public Object usedPoolLock = new Object();
   
      protected int numberOfRetries = MAX_RETRIES;
   
  @@ -405,13 +406,16 @@
            if (pool.size() < maxPoolSize)
            {
               pool.add(socketWrapper);
  +            synchronized(usedPoolLock)
  +            {
               usedPooled--;
            }
  +         }
            else
            {
               if (log.isTraceEnabled())
               {
  -               log.trace("Pool was already full, than we will close the connection");
  +               log.trace("Pool was already full, will close the connection");
               }
               try
               {
  @@ -654,6 +658,8 @@
                  pooled = getPooledConnection();
               }
            }
  +         synchronized(usedPoolLock)
  +         {
            if (pooled != null)
            {
               usedPooled++;
  @@ -690,6 +696,7 @@
               usedPooled++;
               break;
            }
  +         }
            // waiting 1 second (numberOfRetries along with 1 second wait determines timeout on getting pooled connection)
            Thread.sleep(1000);
         }
  
  
  
  1.28      +14 -2     JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServerThread.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -b -r1.27 -r1.28
  --- ServerThread.java	16 Aug 2006 14:20:17 -0000	1.27
  +++ ServerThread.java	23 Aug 2006 03:57:37 -0000	1.28
  @@ -38,6 +38,7 @@
   import java.lang.reflect.Constructor;
   import java.net.Socket;
   import java.net.SocketException;
  +import java.net.SocketTimeoutException;
   import java.util.LinkedList;
   import java.util.Map;
   
  @@ -54,7 +55,7 @@
    *
    * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
    * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
  - * @version $Revision: 1.27 $
  + * @version $Revision: 1.28 $
    */
   public class ServerThread extends Thread
   {
  @@ -548,11 +549,22 @@
               running = false;
   
            }
  +         catch(SocketTimeoutException ste)
  +         {
  +            if(!shutdown)
  +            {
  +               if(isTrace)
  +               {
  +                  log.trace(ste);
  +               }
  +            }
  +            running = false;
  +         }
            catch (InterruptedIOException e)
            {
               if (!shutdown)
               {
  -               log.error("socket timed out", e);
  +               log.error("Socket IO interrupted", e);
               }
               running = false;
   
  
  
  



More information about the jboss-cvs-commits mailing list