From 17748dde7e8014e8c781c4ba91b70edfb08b8bfb Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 19 Jan 2005 06:57:12 +0000 Subject: [PATCH] PR: bug 7769 loader aborts when logger not found in naming service, class renamed in coherence with library name. --- src/SALOMETraceCollector/Makefile.in | 4 +-- .../SALOMETraceCollector.cxx | 7 ++-- .../SALOMETraceCollector.hxx | 2 ++ ...TraceCollector_WaitForServerReadiness.cxx} | 36 +++++++++++-------- ...TraceCollector_WaitForServerReadiness.hxx} | 8 ++--- 5 files changed, 35 insertions(+), 22 deletions(-) rename src/SALOMETraceCollector/{LocalTrace_WaitForServerReadiness.cxx => TraceCollector_WaitForServerReadiness.cxx} (79%) rename src/SALOMETraceCollector/{LocalTrace_WaitForServerReadiness.hxx => TraceCollector_WaitForServerReadiness.hxx} (83%) diff --git a/src/SALOMETraceCollector/Makefile.in b/src/SALOMETraceCollector/Makefile.in index 394805883..3df7820fd 100644 --- a/src/SALOMETraceCollector/Makefile.in +++ b/src/SALOMETraceCollector/Makefile.in @@ -36,7 +36,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl # header files EXPORT_HEADERS= SALOMETraceCollector.hxx \ - LocalTrace_WaitForServerReadiness.hxx + TraceCollector_WaitForServerReadiness.hxx EXPORT_PYSCRIPTS = @@ -44,7 +44,7 @@ EXPORT_PYSCRIPTS = LIB = libSALOMETraceCollector.la LIB_SRC = SALOMETraceCollector.cxx \ - LocalTrace_WaitForServerReadiness.cxx + TraceCollector_WaitForServerReadiness.cxx LIB_CLIENT_IDL = Logger.idl LDFLAGS+= diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index 933670635..1c0709848 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -33,7 +33,7 @@ using namespace std; #include "SALOMETraceCollector.hxx" -#include "LocalTrace_WaitForServerReadiness.hxx" +#include "TraceCollector_WaitForServerReadiness.hxx" //#include "SALOME_Log.hxx" #include #include CORBA_CLIENT_HEADER(Logger) @@ -50,6 +50,9 @@ CORBA::ORB_ptr SALOMETraceCollector::_orb = 0; // ============================================================================ /*! + * This class replaces LocalTraceCollector, which is to use outside SALOME, + * without CORBA. + * * guarantees a unique object instance of the class (singleton thread safe) * a separate thread for loop to print traces is launched. * \param typeTrace 0=standard out, 1=file(/tmp/tracetest.log), 2=CORBA log @@ -155,7 +158,7 @@ void* SALOMETraceCollector::run(void *bid) } break; case 2 : // --- trace collection via CORBA - obj = LocalTrace_WaitForServerReadiness(_orb,"Logger"); + obj = TraceCollector_WaitForServerReadiness(_orb,"Logger"); if (!CORBA::is_nil(obj)) m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); if (CORBA::is_nil(m_pInterfaceLogger)) diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.hxx b/src/SALOMETraceCollector/SALOMETraceCollector.hxx index 846c4adf2..7d1b4bbb8 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.hxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.hxx @@ -31,6 +31,8 @@ #include #include "LocalTraceBufferPool.hxx" +//! See LocalTraceCollector instead of SALOMETraceCollector for usage without CORBA + class SALOMETraceCollector { public: diff --git a/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx similarity index 79% rename from src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx rename to src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx index 75a09525a..9e91b71d9 100644 --- a/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx @@ -19,12 +19,12 @@ // // // -// File : LocalTrace_WaitForServerReadiness.cxx +// File : TraceCollector_WaitForServerReadiness.cxx // Author : Paul RASCLE (EDF) // Module : KERNEL // $Header$ -#include "LocalTrace_WaitForServerReadiness.hxx" +#include "TraceCollector_WaitForServerReadiness.hxx" #include #include @@ -43,10 +43,10 @@ using namespace std; */ // ============================================================================ -CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr orb, - string serverName) +CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, + string serverName) { - long TIMESleep = 250000000; + long TIMESleep = 500000000; int NumberOfTries = 40; timespec ts_req; @@ -68,7 +68,7 @@ CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr orb, CosNaming::Name name; name.length(1); name[0].id = CORBA::string_dup(serverName.c_str()); - CORBA::Object_var theObj; + CORBA::Object_var theObj=CORBA::Object::_nil(); for (int itry=0; itry < NumberOfTries; itry++) { @@ -81,28 +81,36 @@ CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr orb, } catch( CORBA::COMM_FAILURE& ) { - cout << "LocalTrace_WaitForServerReadiness: " + cout << "TraceCollector_WaitForServerReadiness: " << "CORBA::COMM_FAILURE: " << "Unable to contact the Naming Service" << endl; } catch(...) { - cout << "LocalTrace_WaitForServerReadiness: " + cout << "TraceCollector_WaitForServerReadiness: " << "Unknown exception dealing with Naming Service" << endl; } + obj=CORBA::Object::_nil(); if(!CORBA::is_nil(inc)) { - obj = inc->resolve(name); - if (!CORBA::is_nil(obj)) + try { - cout << "LocalTrace_WaitForServerReadiness: " - << serverName << " found in CORBA Name Service" << endl; - break; + obj = inc->resolve(name); + if (!CORBA::is_nil(obj)) + { + cout << "TraceCollector_WaitForServerReadiness: " + << serverName << " found in CORBA Name Service" << endl; + break; + } + } + catch (const CosNaming::NamingContext::NotFound&) + { + cout << "Caught exception: Naming Service can't found Logger"; } } int a = nanosleep(&ts_req,&ts_rem); - cout << "LocalTrace_WaitForServerReadiness: retry look for" + cout << "TraceCollector_WaitForServerReadiness: retry look for" << serverName << endl; } } diff --git a/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx similarity index 83% rename from src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx rename to src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx index a5e1c9a89..c31d11684 100644 --- a/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx @@ -24,13 +24,13 @@ // Module : KERNEL // $Header$ -#ifndef _LOCALTRACE_WAITFORSERVERREADINESS_HXX_ -#define _LOCALTRACE_WAITFORSERVERREADINESS_HXX_ +#ifndef _TRACECOLLECTOR_WAITFORSERVERREADINESS_HXX_ +#define _TRACECOLLECTOR_WAITFORSERVERREADINESS_HXX_ #include #include -CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr theOrb, - std::string serverName); +CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr theOrb, + std::string serverName); #endif -- 2.39.2