From: Anthony Geay Date: Thu, 21 Oct 2021 13:55:53 +0000 (+0200) Subject: In progress X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2F26457_dbg;p=modules%2Fkernel.git In progress --- diff --git a/src/Basics/Test/BasicMainTest.hxx b/src/Basics/Test/BasicMainTest.hxx index 387455b9d..aaaf52d14 100644 --- a/src/Basics/Test/BasicMainTest.hxx +++ b/src/Basics/Test/BasicMainTest.hxx @@ -42,7 +42,7 @@ */ // ============================================================================ -int main() +int main(int argc, char *argv[]) { // --- Create the event manager and test controller CPPUNIT_NS::TestResult controller; diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index 8d69598dc..14f827a90 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -42,7 +42,7 @@ // Class attributes initialisation, for class method SALOMETraceCollector::run -CORBA::ORB_ptr SALOMETraceCollector::_orb = 0; +CORBA::ORB_var SALOMETraceCollector::_orb; // ============================================================================ /*! @@ -62,6 +62,10 @@ BaseTraceCollector* SALOMETraceCollector::instance() if (_singleton == 0) // another thread may have got { // the lock after the first test BaseTraceCollector* myInstance = new SALOMETraceCollector(); + int argc=0; + char *_argv=0; + char ** argv = &_argv; + //_orb = CORBA::ORB_init (argc, argv); _orb = KERNEL::GetRefToORB(); sem_init(&_sem,0,0); // to wait until run thread is initialized @@ -99,7 +103,7 @@ void* SALOMETraceCollector::run(void* /*bid*/) SALOME_Logger::Logger_var m_pInterfaceLogger; CORBA::Object_var obj; - + CORBA::ORB_var _orb = KERNEL::GetRefToORB(); obj = TraceCollector_WaitForServerReadiness(_orb,"Logger"); if (!CORBA::is_nil(obj)) m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.hxx b/src/SALOMETraceCollector/SALOMETraceCollector.hxx index e557dc0eb..081d9237f 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.hxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.hxx @@ -58,7 +58,7 @@ class SALOMETRACECOLLECTOR_EXPORT SALOMETraceCollector: SALOMETraceCollector(); private: - static CORBA::ORB_ptr _orb; + static CORBA::ORB_var _orb; }; #endif diff --git a/src/SALOMETraceCollector/Test/CMakeLists.txt b/src/SALOMETraceCollector/Test/CMakeLists.txt index 8bd3146df..9cc6ee7ef 100644 --- a/src/SALOMETraceCollector/Test/CMakeLists.txt +++ b/src/SALOMETraceCollector/Test/CMakeLists.txt @@ -25,12 +25,14 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMELocalTrace/Test ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMETraceCollector + ${CMAKE_CURRENT_SOURCE_DIR}/../../ArgvKeeper ) SET(COMMON_LIBS SALOMELocalTraceTest SALOMELocalTrace SALOMEBasics + ArgvKeeper ${PTHREAD_LIBRARIES} ${PLATFORM_LIBS} ${CPPUNIT_LIBRARIES} diff --git a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx index 5461210c2..a40e77358 100644 --- a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx @@ -27,7 +27,7 @@ // --- Registers the fixture into the 'registry' -CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest ); +//CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest ); CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest ); // --- generic Main program from Basic/Test diff --git a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx index 040b13db7..2eb590738 100644 --- a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx @@ -28,12 +28,15 @@ #include "TraceCollector_WaitForServerReadiness.hxx" #include #include +#include #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1900 #include #endif +std::mutex mutex; + // ============================================================================ /*! * Wait until a server is registered in naming service. @@ -60,6 +63,7 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, ts_rem.tv_nsec=0; ts_rem.tv_sec=0; + const std::lock_guard lock(mutex); CORBA::Object_var obj; try @@ -78,8 +82,10 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, { try { - if(!CORBA::is_nil(orb)) + if(!CORBA::is_nil(orb)) + { theObj = orb->resolve_initial_references("NameService"); + } if (!CORBA::is_nil(theObj)) inc = CosNaming::NamingContext::_narrow(theObj); } diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index ab39d9375..27be443fd 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -86,13 +86,22 @@ CORBA::ORB_var &ORB_INIT::operator() () } std::vector args = GetArgcArgv(); int argc = args.size(); - char** argv = new char*[argc]; + char** argv = nullptr; + char *dummy = nullptr; + if(argc>0) + { argv = new char*[argc]; } + else + { argv = &dummy; } for (int i = 0; i < argc; ++i) argv[i] = strdup(args.at(i).c_str()); - _orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ; + if(argc>0) + { _orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ; } + else + { _orb = CORBA::ORB_init( argc, argv); } for (int i = 0; i < argc; ++i) delete[] argv[i]; - delete[] argv; + if(argc>0) + delete[] argv; } catch( const CORBA::Exception & ) {