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

Ron Sigal ron_sigal at yahoo.com
Tue Nov 13 04:00:23 EST 2007


  User: rsigal  
  Date: 07/11/13 04:00:23

  Modified:    src/main/org/jboss/remoting/transport/socket  Tag:
                        remoting_2_x SocketServerInvoker.java
  Log:
  JBREM-807, JBREM-821: (1) cancel IdleTimerTask in cleanup(); (2) IdleTimerTask doesn't shut down ServerThreads in synchronized block.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.30.2.15 +71 -54    JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SocketServerInvoker.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java,v
  retrieving revision 1.30.2.14
  retrieving revision 1.30.2.15
  diff -u -b -r1.30.2.14 -r1.30.2.15
  --- SocketServerInvoker.java	12 Nov 2007 06:48:39 -0000	1.30.2.14
  +++ SocketServerInvoker.java	13 Nov 2007 09:00:23 -0000	1.30.2.15
  @@ -35,6 +35,7 @@
   import java.net.InetAddress;
   import java.net.ServerSocket;
   import java.net.Socket;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.Map;
  @@ -49,7 +50,7 @@
    * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
    *
  - * @version $Revision: 1.30.2.14 $
  + * @version $Revision: 1.30.2.15 $
    * @jmx:mbean
    */
   public class SocketServerInvoker extends ServerInvoker implements Runnable, SocketServerInvokerMBean
  @@ -305,6 +306,11 @@
         {
         }
   
  +      if (idleTimerTask != null)
  +      {
  +         idleTimerTask.cancel();
  +      }
  +
         maxPoolSize = 0; // so ServerThreads don't reinsert themselves
         if(acceptThreads != null)
         {
  @@ -320,6 +326,8 @@
            }
         }
   
  +      log.debug(this + " stopped threads in threadpool");
  +      
         // The following code has been changed to avoid a race condition with ServerThread.run() which
         // can result in leaving ServerThreads alive, which causes a memory leak.
         if (clientpool != null)
  @@ -736,12 +744,13 @@
         public void run()
         {
            Object[] svrThreadArray = null;
  +         Set threadsToShutdown = new HashSet();
   
            synchronized(clientpool)
            {
               Set svrThreads = clientpool.getContents();
               svrThreadArray = svrThreads.toArray();
  -         }
  +
            if(trace)
            {
               if(svrThreadArray != null)
  @@ -775,22 +784,21 @@
                        log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be evicted.");
                     }
                     clientpool.remove(svrThread);
  -                  svrThread.shutdown();
  -                  svrThread.unblock();
  +                     threadsToShutdown.add(svrThread);
  +//                     svrThread.shutdown();
  +//                     svrThread.unblock();
                  }
               }
            }
   
            // now check idle server threads in the thread pool
            svrThreadArray = null;
  -         synchronized(threadpool)
  -         {
  +
               if(threadpool.size() > 0)
               {
                  // now need to check the tread pool to remove threads
                  svrThreadArray = threadpool.toArray();
               }
  -         }
   
            if(trace)
            {
  @@ -822,11 +830,20 @@
                        log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be removed from thread pool.");
                     }
                     threadpool.remove(svrThread);
  -                  svrThread.shutdown();
  -               }
  +                     threadsToShutdown.add(svrThread);
  +//                     svrThread.shutdown();
               }
            }
         }
      }
   
  +         Iterator it = threadsToShutdown.iterator();
  +         while (it.hasNext())
  +         {
  +            ServerThread svrThread = (ServerThread) it.next();
  +            svrThread.shutdown();
  +//            svrThread.unblock();
  +         }
  +      }
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list