From f096016f82dae2e137fed8c5746672f3bbe7b848 Mon Sep 17 00:00:00 2001 From: prascle Date: Tue, 18 Oct 2005 07:20:12 +0000 Subject: [PATCH] PR: trace improvement --- src/SALOMELocalTrace/FileTraceCollector.cxx | 3 ++- src/SALOMELocalTrace/LocalTraceBufferPool.cxx | 5 +++-- src/SALOMELocalTrace/LocalTraceCollector.cxx | 3 ++- src/SALOMETraceCollector/SALOMETraceCollector.cxx | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/SALOMELocalTrace/FileTraceCollector.cxx b/src/SALOMELocalTrace/FileTraceCollector.cxx index ce198400f..ba880f6ae 100644 --- a/src/SALOMELocalTrace/FileTraceCollector.cxx +++ b/src/SALOMELocalTrace/FileTraceCollector.cxx @@ -57,7 +57,7 @@ BaseTraceCollector* FileTraceCollector::instance(const char *fileName) if (_singleton == 0) // another thread may have got { // the lock after the first test DEVTRACE("FileTraceCollector:: instance()"); - _singleton = new FileTraceCollector(); + BaseTraceCollector* myInstance = new FileTraceCollector(); _fileName = fileName; DEVTRACE(" _fileName: " << _fileName); @@ -67,6 +67,7 @@ BaseTraceCollector* FileTraceCollector::instance(const char *fileName) int re2 = pthread_create(&traceThread, NULL, FileTraceCollector::run, (void *)bid); sem_wait(&_sem); + _singleton = myInstance; // _singleton known only when init done DEVTRACE("FileTraceCollector:: instance()-end"); } ret = pthread_mutex_unlock(&_singletonMutex); // release lock diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx index d875fe5be..2613d8714 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx @@ -82,10 +82,10 @@ LocalTraceBufferPool* LocalTraceBufferPool::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 LocalTraceBufferPool(); + LocalTraceBufferPool* myInstance = new LocalTraceBufferPool(); DESTRUCTOR_OF *ptrDestroy = - new DESTRUCTOR_OF (*_singleton); + new DESTRUCTOR_OF (*myInstance); // --- start a trace Collector @@ -140,6 +140,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() exit(1); // in case assert is deactivated } } + _singleton = myInstance; } ret = pthread_mutex_unlock(&_singletonMutex); // release lock } diff --git a/src/SALOMELocalTrace/LocalTraceCollector.cxx b/src/SALOMELocalTrace/LocalTraceCollector.cxx index 36f4fea93..559216ac9 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.cxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.cxx @@ -52,7 +52,7 @@ 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; @@ -60,6 +60,7 @@ BaseTraceCollector* LocalTraceCollector::instance() int re2 = pthread_create(&traceThread, NULL, LocalTraceCollector::run, (void *)bid); sem_wait(&_sem); + _singleton = myInstance; // _singleton known only when init done } ret = pthread_mutex_unlock(&_singletonMutex); // release lock } diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index bc1e71ad7..6fd76763f 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -59,7 +59,7 @@ BaseTraceCollector* SALOMETraceCollector::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 SALOMETraceCollector(); + BaseTraceCollector* myInstance = new SALOMETraceCollector(); int argc=0; char *_argv=0; char ** argv = &_argv; @@ -71,6 +71,7 @@ BaseTraceCollector* SALOMETraceCollector::instance() int re2 = pthread_create(&traceThread, NULL, SALOMETraceCollector::run, (void *)bid); sem_wait(&_sem); + _singleton = myInstance; // _singleton known only when init done } ret = pthread_mutex_unlock(&_singletonMutex); // release lock } -- 2.39.2