From 376d140852c289f8ae8ade3c44fec5663e4b15c6 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Thu, 8 Feb 2018 08:00:43 +0100 Subject: [PATCH] mutex on StudyBuilder --- src/SALOMEDS/SALOMEDS_Study.cxx | 5 +++++ src/SALOMEDS/SALOMEDS_StudyBuilder.cxx | 4 ++++ src/SALOMEDS/SALOMEDS_StudyBuilder.hxx | 3 +++ 3 files changed, 12 insertions(+) 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 11de3ed7f..67da087bd 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); -- 2.39.2