From 814eec62e30860da609292f8cbb21f01bfc10f1e Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 2 Nov 2005 11:10:41 +0000 Subject: [PATCH] PR: debug some synchro problems on UnitTests --- src/SALOMELocalTrace/FileTraceCollector.cxx | 7 +++++-- src/SALOMELocalTrace/LocalTraceBufferPool.cxx | 9 ++++++--- src/SALOMELocalTrace/LocalTraceCollector.cxx | 2 +- src/SALOMETraceCollector/SALOMETraceCollector.cxx | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/SALOMELocalTrace/FileTraceCollector.cxx b/src/SALOMELocalTrace/FileTraceCollector.cxx index ba880f6ae..61ac81227 100644 --- a/src/SALOMELocalTrace/FileTraceCollector.cxx +++ b/src/SALOMELocalTrace/FileTraceCollector.cxx @@ -31,6 +31,7 @@ using namespace std; +//#define _DEVDEBUG_ #include "FileTraceCollector.hxx" // Class attributes initialisation, for class method FileTraceCollector::run @@ -88,6 +89,7 @@ BaseTraceCollector* FileTraceCollector::instance(const char *fileName) void* FileTraceCollector::run(void *bid) { + //DEVTRACE("init run"); _threadId = new pthread_t; *_threadId = pthread_self(); sem_post(&_sem); // unlock instance @@ -100,6 +102,7 @@ void* FileTraceCollector::run(void *bid) ofstream traceFile; const char *theFileName = _fileName.c_str(); + DEVTRACE("try to open trace file "<< theFileName); traceFile.open(theFileName, ios::out | ios::app); if (!traceFile) { @@ -109,7 +112,7 @@ void* FileTraceCollector::run(void *bid) // --- Loop until there is no more buffer to print, // and no ask for end from destructor. - + DEVTRACE("Begin loop"); while ((!_threadToClose) || myTraceBuffer->toCollect() ) { if (_threadToClose) @@ -183,8 +186,8 @@ FileTraceCollector:: ~FileTraceCollector() _threadToClose = 0; } _singleton = 0; - ret = pthread_mutex_unlock(&_singletonMutex); // release lock } + ret = pthread_mutex_unlock(&_singletonMutex); // release lock } // ============================================================================ diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx index 2613d8714..8fd4c5bf2 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx @@ -33,6 +33,7 @@ #else #endif +//#define _DEVDEBUG_ #include "LocalTraceBufferPool.hxx" #include "BaseTraceCollector.hxx" #include "LocalTraceCollector.hxx" @@ -82,10 +83,12 @@ 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 - LocalTraceBufferPool* myInstance = new LocalTraceBufferPool(); + DEVTRACE("New buffer pool"); + LocalTraceBufferPool* myInstance = new LocalTraceBufferPool(); DESTRUCTOR_OF *ptrDestroy = new DESTRUCTOR_OF (*myInstance); + _singleton = myInstance; // --- start a trace Collector @@ -140,7 +143,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() exit(1); // in case assert is deactivated } } - _singleton = myInstance; + DEVTRACE("New buffer pool: end"); } ret = pthread_mutex_unlock(&_singletonMutex); // release lock } @@ -295,8 +298,8 @@ LocalTraceBufferPool::~LocalTraceBufferPool() ret=pthread_mutex_destroy(&_incrementMutex); DEVTRACE("LocalTraceBufferPool::~LocalTraceBufferPool()-end"); _singleton = 0; - ret = pthread_mutex_unlock(&_singletonMutex); // release lock } + ret = pthread_mutex_unlock(&_singletonMutex); // release lock } // ============================================================================ diff --git a/src/SALOMELocalTrace/LocalTraceCollector.cxx b/src/SALOMELocalTrace/LocalTraceCollector.cxx index 559216ac9..edaa24690 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.cxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.cxx @@ -153,8 +153,8 @@ LocalTraceCollector:: ~LocalTraceCollector() _threadToClose = 0; } _singleton = 0; - ret = pthread_mutex_unlock(&_singletonMutex); // release lock } + ret = pthread_mutex_unlock(&_singletonMutex); // release lock } // ============================================================================ diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index 6fd76763f..361595a66 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -192,8 +192,8 @@ SALOMETraceCollector:: ~SALOMETraceCollector() _threadToClose = 0; } _singleton = 0; - ret = pthread_mutex_unlock(&_singletonMutex); // release lock } + ret = pthread_mutex_unlock(&_singletonMutex); // release lock } // ============================================================================ -- 2.39.2