diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-02 16:55:15 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-02 16:55:15 +0000 |
commit | 7a589cb97a18ad905339a20824fe5b0bfc90cc9f (patch) | |
tree | f65567a89f46899885dc995324e10368825902d2 /cpp/src/Ice/ConnectionFactory.cpp | |
parent | initial clean-up (diff) | |
download | ice-7a589cb97a18ad905339a20824fe5b0bfc90cc9f.tar.bz2 ice-7a589cb97a18ad905339a20824fe5b0bfc90cc9f.tar.xz ice-7a589cb97a18ad905339a20824fe5b0bfc90cc9f.zip |
finished() fixes
Diffstat (limited to 'cpp/src/Ice/ConnectionFactory.cpp')
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 0053152b5b0..378ce96d84a 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -304,9 +304,10 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&) { IceUtil::Mutex::Lock sync(*this); + _threadPool->promoteFollower(); + if (_state != StateActive) { - _threadPool->promoteFollower(); IceUtil::ThreadControl::yield(); return; } @@ -350,14 +351,6 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&) } setState(StateClosed); } - - _threadPool->promoteFollower(); -} - -void -IceInternal::IncomingConnectionFactory::exception(const LocalException&) -{ - assert(false); // Must not be called. } void @@ -365,41 +358,49 @@ IceInternal::IncomingConnectionFactory::finished() { IceUtil::Mutex::Lock sync(*this); - assert(_state == StateClosed); - - _acceptor->shutdown(); + _threadPool->promoteFollower(); -#ifdef _STLP_BEGIN_NAMESPACE - // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h - for_each(_connections.begin(), _connections.end(), - voidbind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated)); -#else - for_each(_connections.begin(), _connections.end(), - bind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated)); -#endif - _connections.clear(); + assert(_state == StateClosed); + assert(_connections.empty()); - // - // Clear listen() backlog properly by accepting all queued - // connections, and then shutting them down. - // - while (true) + try { - try + // + // Clear listen() backlog properly by accepting all queued + // connections, and then shutting them down. + // + while (true) { - TransceiverPtr transceiver = _acceptor->accept(0); - ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter); - connection->exception(ObjectAdapterDeactivatedException(__FILE__, __LINE__)); + try + { + TransceiverPtr transceiver = _acceptor->accept(0); + ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter); + connection->exception(ObjectAdapterDeactivatedException(__FILE__, __LINE__)); + } + catch (const TimeoutException&) + { + break; // Exit loop on timeout. + } } - catch (const Exception&) + } + catch (const LocalException& ex) + { + if (_warn) { - break; + Warning out(_instance->logger()); + out << "connection exception:\n" << ex << '\n' << _acceptor->toString(); } } _acceptor->close(); } +void +IceInternal::IncomingConnectionFactory::exception(const LocalException&) +{ + assert(false); // Must not be called. +} + /* bool IceInternal::IncomingConnectionFactory::tryDestroy() @@ -513,6 +514,17 @@ IceInternal::IncomingConnectionFactory::setState(State state) } _threadPool->unregister(_acceptor->fd(), true); } + +#ifdef _STLP_BEGIN_NAMESPACE + // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h + for_each(_connections.begin(), _connections.end(), + voidbind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated)); +#else + for_each(_connections.begin(), _connections.end(), + bind2nd(Ice::voidMemFun1(&Connection::destroy), Connection::ObjectAdapterDeactivated)); +#endif + _connections.clear(); + break; } } |