]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
In progress agy/26457_dbg
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 21 Oct 2021 13:55:53 +0000 (15:55 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 21 Oct 2021 13:55:53 +0000 (15:55 +0200)
src/Basics/Test/BasicMainTest.hxx
src/SALOMETraceCollector/SALOMETraceCollector.cxx
src/SALOMETraceCollector/SALOMETraceCollector.hxx
src/SALOMETraceCollector/Test/CMakeLists.txt
src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx
src/Utils/Utils_ORB_INIT.cxx

index 387455b9de1e540f70158ddc93fa2b088be34e90..aaaf52d140e2553d1960fd4dc3289434316b21b2 100644 (file)
@@ -42,7 +42,7 @@
  */
 // ============================================================================
 
-int main()
+int main(int argc, char *argv[])
 {
   // --- Create the event manager and test controller
   CPPUNIT_NS::TestResult controller;
index 8d69598dc88f9124d84b52e0b55d1db5defe1262..14f827a9081a55fdc2431402340b2ca868ce84b6 100644 (file)
@@ -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);
index e557dc0ebd825653f8f6b5bf01141d4815fa572f..081d9237fd0f087998ee9d78887aadef4e55818e 100644 (file)
@@ -58,7 +58,7 @@ class SALOMETRACECOLLECTOR_EXPORT SALOMETraceCollector:
   SALOMETraceCollector();
 
  private:
-  static CORBA::ORB_ptr _orb;
+  static CORBA::ORB_var _orb;
 };
 
 #endif
index 8bd3146dfa7214f23181cc814cb44b8cb8437d63..9cc6ee7efd492e328061cd262066693b91bfb184 100644 (file)
@@ -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}
index 5461210c241f9733655aa0ce405a31718a557e9e..a40e7735890e281156e7e1b2edc6b490d1e9457e 100644 (file)
@@ -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
index 040b13db7e830d39fbd37fff6cf45229cf53bba8..2eb5907382035824b61b93de281da1a74c9e0d02 100644 (file)
 #include "TraceCollector_WaitForServerReadiness.hxx"
 #include <iostream>
 #include <ctime>
+#include <mutex>
 
 
 #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1900
 #include <omnithread/pthread_nt.h>
 #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<std::mutex> 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);
             }  
index ab39d93757241943b89ee1d24d74a8ebcc0fdea5..27be443fd8d76301907a36c7e8f1b0c65328d8b0 100644 (file)
@@ -86,13 +86,22 @@ CORBA::ORB_var &ORB_INIT::operator() ()
             }
             std::vector<std::string> 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 & )
           {