diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 53 | ||||
-rw-r--r-- | cpp/src/Ice/Connection.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 23 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 1 |
4 files changed, 50 insertions, 28 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 9a57f741ece..098b9a20aab 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -802,7 +802,8 @@ IceInternal::Connection::Connection(const InstancePtr& instance, _batchStream(_instance), _responseCount(0), _proxyUsageCount(0), - _state(StateHolding) + _state(StateHolding), + _registeredWithPool(false) { _warn = _instance->properties()->getPropertyAsInt("Ice.ConnectionWarnings") > 0; } @@ -974,38 +975,48 @@ IceInternal::Connection::closeConnection() void IceInternal::Connection::registerWithPool() { - if (_adapter) + if (!_registeredWithPool) { - if (!_serverThreadPool) + if (_adapter) { - _serverThreadPool = _instance->serverThreadPool(); - assert(_serverThreadPool); + if (!_serverThreadPool) + { + _serverThreadPool = _instance->serverThreadPool(); + assert(_serverThreadPool); + } + _serverThreadPool->_register(_transceiver->fd(), this); } - _serverThreadPool->_register(_transceiver->fd(), this); - } - else - { - if (!_clientThreadPool) + else { - _clientThreadPool = _instance->clientThreadPool(); - assert(_clientThreadPool); + if (!_clientThreadPool) + { + _clientThreadPool = _instance->clientThreadPool(); + assert(_clientThreadPool); + } + _clientThreadPool->_register(_transceiver->fd(), this); } - _clientThreadPool->_register(_transceiver->fd(), this); + + _registeredWithPool = true; } } void IceInternal::Connection::unregisterWithPool() { - if (_adapter) + if (_registeredWithPool) { - assert(_serverThreadPool); - _serverThreadPool->unregister(_transceiver->fd()); - } - else - { - assert(_clientThreadPool); - _clientThreadPool->unregister(_transceiver->fd()); + if (_adapter) + { + assert(_serverThreadPool); + _serverThreadPool->unregister(_transceiver->fd()); + } + else + { + assert(_clientThreadPool); + _clientThreadPool->unregister(_transceiver->fd()); + } + + _registeredWithPool = false; } } diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h index ffa47bafc89..0128cd029f8 100644 --- a/cpp/src/Ice/Connection.h +++ b/cpp/src/Ice/Connection.h @@ -113,6 +113,7 @@ private: int _proxyUsageCount; State _state; bool _warn; + bool _registeredWithPool; }; } diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 522354d3cc2..27d8bc94c6c 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -432,7 +432,8 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance _endpoint(endpoint), _adapter(adapter), _state(StateHolding), - _finished(false) + _finished(false), + _registeredWithPool(false) { DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); if (defaultsAndOverrides->overrideTimeout) @@ -554,12 +555,16 @@ IceInternal::IncomingConnectionFactory::registerWithPool() { if (_acceptor) { - if (!_serverThreadPool) + if (!_registeredWithPool) { - _serverThreadPool = _instance->serverThreadPool(); - assert(_serverThreadPool); + if (!_serverThreadPool) + { + _serverThreadPool = _instance->serverThreadPool(); + assert(_serverThreadPool); + } + _serverThreadPool->_register(_acceptor->fd(), this); + _registeredWithPool = true; } - _serverThreadPool->_register(_acceptor->fd(), this); } } @@ -568,7 +573,11 @@ IceInternal::IncomingConnectionFactory::unregisterWithPool() { if (_acceptor) { - assert(_serverThreadPool); - _serverThreadPool->unregister(_acceptor->fd()); + if (_registeredWithPool) + { + assert(_serverThreadPool); + _serverThreadPool->unregister(_acceptor->fd()); + _registeredWithPool = false; + } } } diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 34f778d075d..3bc7ef90860 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -101,6 +101,7 @@ private: State _state; bool _warn; bool _finished; + bool _registeredWithPool; }; } |