#include <cstdlib>
#include <omniORB4/CORBA.h>
-#include "OpUtil.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "SALOMETraceCollector.hxx"
#include "TraceCollector_WaitForServerReadiness.hxx"
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(Logger)
-// Class attributes initialisation, for class method SALOMETraceCollector::run
-
-CORBA::ORB_ptr SALOMETraceCollector::_orb = 0;
-
// ============================================================================
/*!
* This class is for use with CORBA, inside SALOME.
if (_singleton == 0) // another thread may have got
{ // the lock after the first test
BaseTraceCollector* myInstance = new SALOMETraceCollector();
- _orb = KERNEL::GetRefToORB();
sem_init(&_sem,0,0); // to wait until run thread is initialized
pthread_t traceThread;
SALOME_Logger::Logger_var m_pInterfaceLogger;
CORBA::Object_var obj;
- obj = TraceCollector_WaitForServerReadiness(_orb,"Logger");
+ obj = TraceCollector_WaitForServerReadiness("Logger");
if (!CORBA::is_nil(obj))
m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj);
if (CORBA::is_nil(m_pInterfaceLogger))
}
myTraceBuffer->retrieve(myTrace);
- if (!CORBA::is_nil(_orb))
+ //if (!CORBA::is_nil(_orb))
+ if (true)
{
if (myTrace.traceType == ABORT_MESS)
{
#define _SALOMETRACECOLLECTOR_HXX_
#include <string>
-#include <omniORB4/CORBA.h>
#include "BaseTraceCollector.hxx"
#include "LocalTraceBufferPool.hxx"
protected:
SALOMETraceCollector();
-
- private:
- static CORBA::ORB_ptr _orb;
};
#endif
void
SALOMETraceCollectorTest::testLoadBufferPoolCORBA()
{
+ LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
std::string s = "with_logger";
CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
}
MESSAGE(" ---- end of PrintHello threads ---- ");
- LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
CPPUNIT_ASSERT(bp1);
bp1->deleteInstance(bp1);
}
// --- 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
# execute Unit Test
command = ['./TestSALOMETraceCollector']
+valgrind = ['valgrind', '--leak-check=full']
+#command = valgrind+command
ret = subprocess.call(command)
# kill Test process
// $Header$
//
#include "TraceCollector_WaitForServerReadiness.hxx"
+#include "OpUtil.hxx"
#include <iostream>
#include <ctime>
*/
// ============================================================================
-CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb,
- std::string serverName)
+CORBA::Object_ptr TraceCollector_WaitForServerReadiness(const std::string& serverName)
{
long TIMESleep = 500000000;
int NumberOfTries = 40;
ts_rem.tv_nsec=0;
ts_rem.tv_sec=0;
+ CORBA::ORB_var orb = KERNEL::GetRefToORB();
CORBA::Object_var obj;
try
#include <omniORB4/CORBA.h>
#include <string>
-CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr theOrb,
- std::string serverName);
+CORBA::Object_ptr TraceCollector_WaitForServerReadiness(const std::string& serverName);
#endif
// Module : SALOME
//
#include "OpUtil.hxx"
+#include <mutex>
#if !defined(SALOME_LIGHT)
#include "Utils_SINGLETON.hxx"
#include "Utils_ORB_INIT.hxx"
+namespace
+{
+ std::recursive_mutex mutex; //!< mutex to protect access to static data
+}
+
UTILS_EXPORT CORBA::ORB_var KERNEL::GetRefToORB()
{
+ std::lock_guard<std::recursive_mutex> g(mutex);
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
- CORBA::ORB_var &orb = init();
+ CORBA::ORB_var orb = init();
return orb;
}
# include <string>
# include <vector>
+#include <mutex>
ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() )
{
}
+namespace
+{
+ std::recursive_mutex mutex; //!< mutex to protect access to static data
+}
ORB_INIT::~ORB_INIT()
{
CORBA::ORB_var &ORB_INIT::operator() ()
{
try {
+ std::lock_guard<std::recursive_mutex> g(mutex);
if ( CORBA::is_nil( _orb ) )
{
try
}
std::vector<std::string> args = GetArgcArgv();
int argc = args.size();
- char** argv = new char*[argc];
- for (int i = 0; i < argc; ++i)
- argv[i] = strdup(args.at(i).c_str());
+ char** argv = argc > 0 ? new char*[argc] : nullptr;
+ for (int i = 0; i < argc; ++i) {
+ argv[i] = new char[args.at(i).size()+1];
+ strcpy(argv[i], args.at(i).c_str());
+ }
_orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ;
for (int i = 0; i < argc; ++i)
delete[] argv[i];
- delete[] argv;
+ if (argc>0)
+ delete[] argv;
}
catch( const CORBA::Exception & )
{