summaryrefslogtreecommitdiff
path: root/php/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-02-06 11:59:43 +0100
committerBenoit Foucher <benoit@zeroc.com>2018-02-06 11:59:43 +0100
commit11b14df0983a132cea813c7774aeb45ca062774a (patch)
tree5be7db53d258515fcfd6fe8ce37b83ef9e6a854f /php/src
parentFixed bogus assert when compiling PHP module with debug (ICE-8629) (diff)
downloadice-11b14df0983a132cea813c7774aeb45ca062774a.tar.bz2
ice-11b14df0983a132cea813c7774aeb45ca062774a.tar.xz
ice-11b14df0983a132cea813c7774aeb45ca062774a.zip
Fixed IcePHP assert that would occur with a PHP debug executable when destroying multiple times the same communicator (ICE-8635)
Diffstat (limited to 'php/src')
-rw-r--r--php/src/php5/Communicator.cpp52
-rw-r--r--php/src/php7/Communicator.cpp52
2 files changed, 46 insertions, 58 deletions
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<CommunicatorInfoIPtr>::value(getThis() TSRMLS_CC);
assert(_this);
- //
- // Remove all registrations.
- //
- {
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(_registeredCommunicatorsMutex);
- for(vector<string>::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<CommunicatorMap*>(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<IceUtil::Mutex> lock(_registeredCommunicatorsMutex);
+ for(vector<string>::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)
diff --git a/php/src/php7/Communicator.cpp b/php/src/php7/Communicator.cpp
index 78f957f1517..4dd3018eae2 100644
--- a/php/src/php7/Communicator.cpp
+++ b/php/src/php7/Communicator.cpp
@@ -276,43 +276,37 @@ ZEND_METHOD(Ice_Communicator, destroy)
CommunicatorInfoIPtr _this = Wrapper<CommunicatorInfoIPtr>::value(getThis());
assert(_this);
- //
- // Remove all registrations.
- //
- {
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(_registeredCommunicatorsMutex);
- for(vector<string>::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();
-
Ice::CommunicatorPtr c = _this->getCommunicator();
assert(c);
CommunicatorMap* m = reinterpret_cast<CommunicatorMap*>(ICE_G(communicatorMap));
assert(m);
- assert(m->find(c) != m->end());
- m->erase(c);
+ if(m->find(c) != m->end())
+ {
+ m->erase(c);
+
+ //
+ // Remove all registrations.
+ //
+ {
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(_registeredCommunicatorsMutex);
+ for(vector<string>::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();
+
+ ValueFactoryManagerPtr vfm = ValueFactoryManagerPtr::dynamicCast(c->getValueFactoryManager());
+ assert(vfm);
+ vfm->destroy();
- try
- {
c->destroy();
}
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex);
- RETURN_NULL();
- }
}
ZEND_METHOD(Ice_Communicator, stringToProxy)