From: Paul RASCLE Date: Thu, 8 Feb 2018 07:00:43 +0000 (+0100) Subject: mutex on StudyBuilder X-Git-Tag: V8_5_0a2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=48785647193c10a2f4df17bfe4daee4c15fae3fe;p=modules%2Fkernel.git mutex on StudyBuilder --- diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 63d44b5ac..50d658b7d 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -68,6 +68,9 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy) _isLocal = true; _local_impl = theStudy; _corba_impl = SALOMEDS::Study::_nil(); + + pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 ); + init_orb(); } @@ -79,6 +82,8 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) long pid = (long)getpid(); #endif + pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 ); + long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index f23777af1..8aeed232c 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -50,6 +50,8 @@ #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +pthread_mutex_t SALOMEDS_StudyBuilder::_remoteBuilderMutex; + SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuilder) { _isLocal = true; @@ -61,6 +63,7 @@ SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuild SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder) { + pthread_mutex_lock( &_remoteBuilderMutex ); _isLocal = false; _local_impl = NULL; _corba_impl = SALOMEDS::StudyBuilder::_duplicate(theBuilder); @@ -70,6 +73,7 @@ SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuild SALOMEDS_StudyBuilder::~SALOMEDS_StudyBuilder() { + if (!_isLocal) pthread_mutex_unlock( &_remoteBuilderMutex ); } _PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& ComponentDataType) diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx index b7e3a6160..37336327f 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx @@ -31,6 +31,7 @@ #include "SALOMEDSClient.hxx" #include "SALOMEDSImpl_StudyBuilder.hxx" +#include // IDL headers #include @@ -44,7 +45,9 @@ private: SALOMEDS::StudyBuilder_var _corba_impl; CORBA::ORB_var _orb; + public: + static pthread_mutex_t _remoteBuilderMutex; SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuilder); SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder);