From b0891e5bd2cb54ae854cc22014cb7e993a89b693 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 21 Jul 2015 16:08:09 +0200 Subject: [PATCH] First tests OK. --- idl/SALOME_SDS.idl | 1 + src/SALOMESDS/SALOMESDS_DataScopeServer.cxx | 15 ++++++++++++--- src/SALOMESDS/SALOMESDS_KeyWaiter.cxx | 4 +++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl index d26c2ad58..b6685b0ba 100644 --- a/idl/SALOME_SDS.idl +++ b/idl/SALOME_SDS.idl @@ -92,6 +92,7 @@ module SALOME Transaction createRdOnlyVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); Transaction createRdExtVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); Transaction createRdWrVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); + Transaction addKeyValueInVarHard(in string varName, in ByteVec keyValue, in ByteVec constValue) raises (SALOME::SALOME_Exception); KeyWaiter waitForKeyInVar(in string varName, in ByteVec keyVal) raises (SALOME::SALOME_Exception); void atomicApply(in ListOfTransaction transactions) raises (SALOME::SALOME_Exception); }; diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx index e1c35d127..0c5c3506e 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx @@ -331,7 +331,16 @@ DataScopeServerTransaction::DataScopeServerTransaction(CORBA::ORB_ptr orb, const { CORBA::Object_var obj(_orb->resolve_initial_references("RootPOA")); PortableServer::POA_var poa(PortableServer::POA::_narrow(obj)); - _poa_for_key_waiter=poa; + // + PortableServer::POAManager_var mgr(poa->the_POAManager()); + CORBA::PolicyList policies; + policies.length(1); + PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL)); + policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol); + PortableServer::POA_var poa2(poa->create_POA("POAForWaiters",mgr,policies)); + threadPol->destroy(); + // + _poa_for_key_waiter=poa2; } DataScopeServerTransaction::DataScopeServerTransaction(const DataScopeServerTransaction& other):DataScopeServerBase(other),_poa_for_key_waiter(other.getPOA4KeyWaiter()) @@ -477,7 +486,7 @@ void DataScopeServerTransaction::notifyKey(PyObject *keyObj, PyObject *valueObj) SALOME::Transaction_ptr DataScopeServerTransaction::addKeyValueInVarHard(const char *varName, const SALOME::ByteVec& key, const SALOME::ByteVec& value) { - checkNotAlreadyExistingVar(varName); + checkVarExistingAndDict(varName); TransactionAddKeyValueHard *ret(new TransactionAddKeyValueHard(this,varName,key,value)); CORBA::Object_var obj(ret->activate()); return SALOME::Transaction::_narrow(obj); @@ -495,7 +504,7 @@ class TrustTransaction { public: TrustTransaction():_must_rollback(0),_ptr(0) { } - void setTransaction(Transaction *t, bool *mustRollback) { if(!t || !mustRollback) throw Exception("TrustTransaction Error #1"); _must_rollback=mustRollback; t->prepareRollBackInCaseOfFailure(); } + void setTransaction(Transaction *t, bool *mustRollback) { if(!t || !mustRollback) throw Exception("TrustTransaction Error #1"); _ptr=t; _must_rollback=mustRollback; _ptr->prepareRollBackInCaseOfFailure(); } void operate() { _ptr->perform(); } ~TrustTransaction() { if(!_ptr) return ; if(*_must_rollback) _ptr->rollBack(); } private: diff --git a/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx b/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx index 0c28da39d..ecc3a9148 100644 --- a/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx +++ b/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx @@ -85,7 +85,9 @@ SALOME::ByteVec *KeyWaiter::waitFor() throw Exception("KeyWaiter::waitFor : internal error !"); Py_XINCREF(_ze_value); std::string st(PickelizedPyObjServer::Pickelize(_ze_value,_var->getFather())); - return PickelizedPyObjServer::FromCppToByteSeq(st); + SALOME::ByteVec *ret(PickelizedPyObjServer::FromCppToByteSeq(st)); + enforcedRelease(); + return ret; } /*! -- 2.39.2