nacho       01/08/24 17:59:03

  Modified:    src/share/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Fix for Bugzilla#1745
  
  Possible problem with thread initialization in ThreadPool.java
  
  Reported by clay.olbon at raremedium.com
  
  Revision  Changes    Path
  1.5       +27 -26    
jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ThreadPool.java   2001/04/21 18:42:51     1.4
  +++ ThreadPool.java   2001/08/25 00:59:03     1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java,v 
1.4 2001/04/21 18:42:51 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/04/21 18:42:51 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/ThreadPool.java,v 
1.5 2001/08/25 00:59:03 nacho Exp $
  + * $Revision: 1.5 $
  + * $Date: 2001/08/25 00:59:03 $
    *
    * ====================================================================
    *
  @@ -253,8 +253,8 @@
                   try {
                       ((ControlRunnable)(pool.elementAt(i))).terminate();
                   } catch(Throwable t) {
  -                    /* 
  -                  * Do nothing... The show must go on, we are shutting 
  +                    /*
  +                  * Do nothing... The show must go on, we are shutting
                     * down the pool and nothing should stop that.
                     */
                    loghelper.log("Ignored exception while shutting down thread pool", 
t, Log.ERROR);
  @@ -267,7 +267,7 @@
       }
   
       /**
  -     * Called by the monitor thread to harvest idel threads.
  +     * Called by the monitor thread to harvest idle threads.
        */
       protected synchronized void checkSpareControllers() {
   
  @@ -307,7 +307,7 @@
       /**
        * Inform the pool that the specific thread finish.
        *
  -     * Called by the ControlRunnable.run() when the runnable 
  +     * Called by the ControlRunnable.run() when the runnable
        * throws an exception.
        */
       protected synchronized void notifyThreadEnd(ControlRunnable c) {
  @@ -315,7 +315,7 @@
           currentThreadCount --;
           notify();
       }
  -    
  +
   
       /*
        * Checks for problematic configuration and fix it.
  @@ -331,7 +331,7 @@
               maxSpareThreads = maxThreads;
           }
   
  -             if(maxSpareThreads <= 0) {
  +        if(maxSpareThreads <= 0) {
               if(1 == maxThreads) {
                   maxSpareThreads = 1;
               } else {
  @@ -341,9 +341,9 @@
   
           if(minSpareThreads >  maxSpareThreads) {
               minSpareThreads =  maxSpareThreads;
  -             }
  +        }
   
  -             if(minSpareThreads <= 0) {
  +        if(minSpareThreads <= 0) {
               if(1 == maxSpareThreads) {
                   minSpareThreads = 1;
               } else {
  @@ -475,31 +475,31 @@
           }
   
           public void run() {
  -            
  +
               while(true) {
  -                try {                     
  +                try {
                            /* Wait for work. */
                       synchronized(this) {
                           if(!shouldRun && !shouldTerminate) {
                               this.wait();
                           }
  +                    }
  +                    if(toRun == null ) {
  +                            if( p.debug>0) p.log( "No toRun ???");
                       }
  -                         if(toRun == null ) {
  -                                 if( p.debug>0) p.log( "No toRun ???");
  -                         }
  -
  -                         if( shouldTerminate ) {
  -                                 if( p.debug>0) p.log( "Terminate");
  -                                 break;
  -                         }
   
  +                    if( shouldTerminate ) {
  +                            if( p.debug>0) p.log( "Terminate");
  +                            break;
  +                    }
  +
                       /* Check if should execute a runnable.  */
                       try {
  -                                 if(noThData) {
  -                                     if(p.debug>0) p.log( "Getting new thread 
data");
  -                                     thData=toRun.getInitData();
  -                                     noThData = false;
  -                                 }
  +                        if(noThData) {
  +                            if(p.debug>0) p.log( "Getting new thread data");
  +                            thData=toRun.getInitData();
  +                            noThData = false;
  +                        }
   
                           if(shouldRun) {
                               toRun.runIt(thData);
  @@ -545,6 +545,7 @@
                throw new NullPointerException("No Runnable");
            }
               this.toRun = toRun;
  +            noThData = true;
               shouldRun = true;
               this.notify();
           }
  
  
  

Reply via email to