diff options
author | Marc Laukien <marc@zeroc.com> | 2005-09-22 19:25:03 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2005-09-22 19:25:03 +0000 |
commit | 7677d7afde77b638f12285989c312ae61668e316 (patch) | |
tree | 76f5ac0d3ece800e008b5e3f0a7ea33ac1c7f624 /cpp/src | |
parent | Propagate service-order move in template to instances (diff) | |
download | ice-7677d7afde77b638f12285989c312ae61668e316.tar.bz2 ice-7677d7afde77b638f12285989c312ae61668e316.tar.xz ice-7677d7afde77b638f12285989c312ae61668e316.zip |
hold fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 46 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 11 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.h | 1 |
4 files changed, 35 insertions, 35 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index b720f2b274c..6326501067f 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -789,11 +789,9 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool threadPool->promoteFollower(); - if(_state == StateActive) - { - registerWithPool(); - } - else if(_state == StateClosed) + --_finishedCount; + + if(_finishedCount == 0 && _state == StateClosed) { _acceptor->close(); _acceptor = 0; @@ -828,6 +826,7 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance _endpoint(endpoint), _adapter(adapter), _registeredWithPool(false), + _finishedCount(0), _warn(_instance->properties()->getPropertyAsInt("Ice.Warn.Connections") > 0), _state(StateHolding) { @@ -938,7 +937,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) { return; } - if(!_instance->threadPerConnection()) + if(!_instance->threadPerConnection() && _acceptor) { registerWithPool(); } @@ -952,7 +951,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) { return; } - if(!_instance->threadPerConnection()) + if(!_instance->threadPerConnection() && _acceptor) { unregisterWithPool(); } @@ -962,27 +961,23 @@ IceInternal::IncomingConnectionFactory::setState(State state) case StateClosed: { - if(_instance->threadPerConnection()) + if(_instance->threadPerConnection() && _acceptor) { - if(_acceptor) - { - // - // Connect to our own acceptor, which unblocks our - // thread per incoming connection factory stuck in accept(). - // - _acceptor->connectToSelf(); - } + // + // If we are in thread per connection mode, we connect + // to our own acceptor, which unblocks our thread per + // incoming connection factory stuck in accept(). + // + _acceptor->connectToSelf(); } else { // - // If we come from holding state, we first need to - // register again before we unregister. + // Otherwise we first must make sure that we are + // registered, then we unregister, and let finished() + // do the close. // - if(_state == StateHolding) - { - registerWithPool(); - } + registerWithPool(); unregisterWithPool(); } @@ -1006,8 +1001,9 @@ void IceInternal::IncomingConnectionFactory::registerWithPool() { assert(!_instance->threadPerConnection()); // Only for use with a thread pool. + assert(_acceptor); // Not for datagram connections. - if(_acceptor && !_registeredWithPool) + if(!_registeredWithPool) { dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_acceptor->fd(), this); _registeredWithPool = true; @@ -1018,11 +1014,13 @@ void IceInternal::IncomingConnectionFactory::unregisterWithPool() { assert(!_instance->threadPerConnection()); // Only for use with a thread pool. + assert(_acceptor); // Not for datagram connections. - if(_acceptor && _registeredWithPool) + if(_registeredWithPool) { dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_acceptor->fd()); _registeredWithPool = false; + ++_finishedCount; // For each unregistration, finished() is called once. } } diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 9beccb40c31..f2645215edb 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -46,7 +46,7 @@ public: Ice::ConnectionIPtr create(const std::vector<EndpointIPtr>&, bool&); void setRouterInfo(const RouterInfoPtr&); - void removeAdapter(const ::Ice::ObjectAdapterPtr&); + void removeAdapter(const Ice::ObjectAdapterPtr&); void flushBatchRequests(); private: @@ -85,14 +85,14 @@ public: virtual void read(BasicStream&); virtual void message(BasicStream&, const ThreadPoolPtr&); virtual void finished(const ThreadPoolPtr&); - virtual void exception(const ::Ice::LocalException&); + virtual void exception(const Ice::LocalException&); virtual std::string toString() const; private: - IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const ::Ice::ObjectAdapterPtr&); + IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const Ice::ObjectAdapterPtr&); virtual ~IncomingConnectionFactory(); - friend class ::Ice::ObjectAdapterI; + friend class Ice::ObjectAdapterI; enum State { @@ -125,9 +125,10 @@ private: const TransceiverPtr _transceiver; const EndpointIPtr _endpoint; - const ::Ice::ObjectAdapterPtr _adapter; + const Ice::ObjectAdapterPtr _adapter; bool _registeredWithPool; + int _finishedCount; const bool _warn; diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 0e3bf717d02..69e0f7a672a 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -292,7 +292,7 @@ Ice::ConnectionI::isFinished() const return false; } - if(_transceiver != 0 || _dispatchCount != 0 || + if(_transceiver || _dispatchCount != 0 || (_threadPerConnection && _threadPerConnection->getThreadControl().isAlive())) { return false; @@ -1295,11 +1295,9 @@ Ice::ConnectionI::finished(const ThreadPoolPtr& threadPool) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if(_state == StateActive || _state == StateClosing) - { - registerWithPool(); - } - else if(_state == StateClosed) + --_finishedCount; + + if(_finishedCount == 0 && _state == StateClosed) { // // We must make sure that nobody is sending when we close @@ -1384,6 +1382,7 @@ Ice::ConnectionI::ConnectionI(const InstancePtr& instance, _logger(_instance->logger()), // Cached for better performance. _traceLevels(_instance->traceLevels()), // Cached for better performance. _registeredWithPool(false), + _finishedCount(0), _warn(_instance->properties()->getPropertyAsInt("Ice.Warn.Connections") > 0), _acmTimeout(0), _requestHdr(headerSize + sizeof(Int), 0), @@ -1838,6 +1837,7 @@ Ice::ConnectionI::unregisterWithPool() { _threadPool->unregister(_transceiver->fd()); _registeredWithPool = false; + ++_finishedCount; // For each unregistration, finished() is called once. } } diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 046eb3404a6..8717fea2dd9 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -155,6 +155,7 @@ private: const IceInternal::TraceLevelsPtr _traceLevels; bool _registeredWithPool; + int _finishedCount; const IceInternal::ThreadPoolPtr _threadPool; const bool _warn; |