Salome HOME
Fix compilation pb.
[modules/kernel.git] / src / SALOMELocalTrace / LocalTraceCollector.cxx
index 36f4fea933bef225e5f9bdfeb63a05808f78edaa..6cbaed7b557eddbfb97b7fcb43ee6e4aad914589 100644 (file)
@@ -15,7 +15,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -52,14 +52,14 @@ BaseTraceCollector* LocalTraceCollector::instance()
       ret = pthread_mutex_lock(&_singletonMutex); // acquire lock to be alone
       if (_singleton == 0)                     // another thread may have got
        {                                      // the lock after the first test
-         _singleton = new LocalTraceCollector();
+         BaseTraceCollector* myInstance = new LocalTraceCollector();
 
          sem_init(&_sem,0,0); // to wait until run thread is initialized
          pthread_t traceThread;
-         int bid;
          int re2 = pthread_create(&traceThread, NULL,
-                                  LocalTraceCollector::run, (void *)bid);
+                                  LocalTraceCollector::run, NULL);
          sem_wait(&_sem);
+         _singleton = myInstance; // _singleton known only when init done
        }
       ret = pthread_mutex_unlock(&_singletonMutex); // release lock
     }
@@ -152,8 +152,8 @@ LocalTraceCollector:: ~LocalTraceCollector()
          _threadToClose = 0;
        }
       _singleton = 0;
-      ret = pthread_mutex_unlock(&_singletonMutex); // release lock
     }
+  ret = pthread_mutex_unlock(&_singletonMutex); // release lock
 }
 
 // ============================================================================