From 2b75f5184257a44bcde209c818f7ccaf65174759 Mon Sep 17 00:00:00 2001 From: prascle Date: Tue, 18 Oct 2005 15:07:13 +0000 Subject: [PATCH] PR: merge from BR_UnitTests (tag mergeto_trunk_18oct05) improvement trace when shutdown --- bin/addToKillList.py | 73 ++++++++++++++----- src/Container/Container_i.cxx | 1 + src/Container/SALOME_ContainerManager.cxx | 6 +- src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py | 5 +- src/SALOMELocalTrace/FileTraceCollector.cxx | 3 +- src/SALOMELocalTrace/LocalTraceBufferPool.cxx | 5 +- src/SALOMELocalTrace/LocalTraceCollector.cxx | 3 +- .../SALOMETraceCollector.cxx | 3 +- 8 files changed, 75 insertions(+), 24 deletions(-) diff --git a/bin/addToKillList.py b/bin/addToKillList.py index 7dad20eb1..2d26f6698 100755 --- a/bin/addToKillList.py +++ b/bin/addToKillList.py @@ -1,26 +1,34 @@ #!/usr/bin/env python -import os, sys, pickle, string +import os, sys, pickle, string, signal ########## adds to the kill list of SALOME one more process ########## -def addToKillList(command_pid, command): - command=(command.split(" "))[0] - my_port = 2809 - try: - file = open(os.environ["OMNIORB_CONFIG"], "r") - s = file.read() - while len(s): - l = string.split(s, ":") - if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : - my_port = int(l[len(l)-1]) - pass - s = file.read() +def findFileDict(): + if os.environ.has_key('NSPORT'): + my_port = os.environ['NSPORT'] pass - except: - pass - #print "myport = ", my_port - + else: + my_port = 2809 + try: + file = open(os.environ["OMNIORB_CONFIG"], "r") + s = file.read() + while len(s): + l = string.split(s, ":") + if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : + my_port = int(l[len(l)-1]) + pass + s = file.read() + pass + pass + except: + pass + pass + print "myport = ", my_port + return my_port + +def addToKillList(command_pid, command): + my_port = findFileDict() filedict=os.getenv("HOME")+'/'+os.getenv('USER')+"_"+str(my_port)+'_SALOME_pidict' try: fpid=open(filedict, 'r') @@ -37,8 +45,11 @@ def addToKillList(command_pid, command): #print "see process %s : %s"% (pid, cmd[0]) if pid == command_pid: already_in=1 + pass + pass pass + command=(command.split(" "))[0] if already_in == 0: try: process_ids.append({command_pid: [command]}) @@ -49,6 +60,34 @@ def addToKillList(command_pid, command): print "addToKillList: can not add command %s to the kill list"% filedict pass pass + pass + +def killList(): + my_port = findFileDict() + filedict=os.getenv("HOME")+'/'+os.getenv('USER')+"_"+str(my_port)+'_SALOME_pidict' + try: + fpid=open(filedict, 'r') + process_ids=pickle.load(fpid) + fpid.close() + except: + process_ids=[{}] + pass + + for process_id in process_ids: + print process_id + for pid, cmd in process_id.items(): + print "stop process %s : %s"% (pid, cmd[0]) + try: + os.kill(int(pid),signal.SIGKILL) + except: + print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) + pass + pass + pass + os.remove(filedict) + pass + + if __name__ == "__main__": print sys.argv diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 62b58f98a..a893cbf03 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -262,6 +262,7 @@ void Engines_Container_i::Shutdown() //_poa->deactivate_object(*_id); if(_isServantAloneInProcess) { + MESSAGE("Effective Shutdown of container Begins..."); LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance(); bp1->deleteInstance(bp1); _orb->shutdown(0); diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index de43d8696..b7a3c708e 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -97,7 +97,11 @@ void SALOME_ContainerManager::ShutdownContainers() CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); Engines::Container_var cont=Engines::Container::_narrow(obj); if(!CORBA::is_nil(cont)) - cont->Shutdown(); + { + MESSAGE("ShutdownContainers: " << (*iter)); + cont->Shutdown(); + } + else MESSAGE("ShutdownContainers: no container ref for " << (*iter)); } } diff --git a/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py b/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py index a1c7135fe..0b6d0e6a3 100644 --- a/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py +++ b/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py @@ -3,6 +3,7 @@ import sys, os,signal,string,commands import runSalome import orbmodule import TestKiller +import addToKillList # get SALOME environment : @@ -62,6 +63,8 @@ import Engines containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager) containerManager.Shutdown() -# kill Test process +# kill Test process + +addToKillList.killList() TestKiller.killProcess(runSalome.process_id) 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