From 11b14df0983a132cea813c7774aeb45ca062774a Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Tue, 6 Feb 2018 11:59:43 +0100 Subject: Fixed IcePHP assert that would occur with a PHP debug executable when destroying multiple times the same communicator (ICE-8635) --- php/src/php5/Communicator.cpp | 52 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'php/src/php5/Communicator.cpp') diff --git a/php/src/php5/Communicator.cpp b/php/src/php5/Communicator.cpp index 333f0073675..bc12e0b8dd8 100644 --- a/php/src/php5/Communicator.cpp +++ b/php/src/php5/Communicator.cpp @@ -270,43 +270,37 @@ ZEND_METHOD(Ice_Communicator, destroy) CommunicatorInfoIPtr _this = Wrapper::value(getThis() TSRMLS_CC); assert(_this); - // - // Remove all registrations. - // - { - IceUtilInternal::MutexPtrLock lock(_registeredCommunicatorsMutex); - for(vector::iterator p = _this->ac->ids.begin(); p != _this->ac->ids.end(); ++p) - { - _registeredCommunicators.erase(*p); - } - _this->ac->ids.clear(); - } - - // - // We need to destroy any object|value factories installed by this request. - // - _this->destroyFactories(TSRMLS_C); - Ice::CommunicatorPtr c = _this->getCommunicator(); assert(c); CommunicatorMap* m = reinterpret_cast(ICE_G(communicatorMap)); assert(m); - assert(m->find(c) != m->end()); - m->erase(c); + if(m->find(c) != m->end()) // If not already destroyed + { + m->erase(c); + + // + // Remove all registrations. + // + { + IceUtilInternal::MutexPtrLock lock(_registeredCommunicatorsMutex); + for(vector::iterator p = _this->ac->ids.begin(); p != _this->ac->ids.end(); ++p) + { + _registeredCommunicators.erase(*p); + } + _this->ac->ids.clear(); + } - ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(c->getValueFactoryManager()); - assert(vfm); - vfm->destroy(); + // + // We need to destroy any object|value factories installed by this request. + // + _this->destroyFactories(TSRMLS_C); + + ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(c->getValueFactoryManager()); + assert(vfm); + vfm->destroy(); - try - { c->destroy(); } - catch(const IceUtil::Exception& ex) - { - throwException(ex TSRMLS_CC); - RETURN_NULL(); - } } ZEND_METHOD(Ice_Communicator, stringToProxy) -- cgit v1.2.3