diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-01-28 08:19:28 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-01-28 08:19:28 +0000 |
commit | 7336033e31741198e531ddf823384a8b60563d69 (patch) | |
tree | 599bdde8fd2228f061b8e0ad840aa8c74acfa9ce /cpp/src | |
parent | fixes (diff) | |
download | ice-7336033e31741198e531ddf823384a8b60563d69.tar.bz2 ice-7336033e31741198e531ddf823384a8b60563d69.tar.xz ice-7336033e31741198e531ddf823384a8b60563d69.zip |
The object adapter thread pool is not created anymore if thread per
connection is enabled.
Added more error & exception handling in the IncomingConnectionFactory.
Fixed a bug where the wrong thread pool was used by the
IncomingConnectionFactory.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 55 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 11 |
3 files changed, 40 insertions, 27 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index a62ad4ea906..65bbba941cd 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -838,26 +838,16 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance assert(_acceptor); _acceptor->listen(); - if(!_instance->threadPerConnection()) + if(_instance->threadPerConnection()) { - // - // Only set _threadPool if we really need it, i.e., if we are - // not in thread per connection mode. Thread pools have lazy - // initialization in Instance, and we don't want them to be - // created if they are not needed. - // - const_cast<ThreadPoolPtr&>(_threadPool) = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool(); - } - else - { - // - // If we are in thread per connection mode, we also use - // one thread per incoming connection factory, that - // accepts new connections on this endpoint. - // __setNoDelete(true); try { + // + // If we are in thread per connection mode, we also use + // one thread per incoming connection factory, that + // accepts new connections on this endpoint. + // _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory(this); _threadPerIncomingConnectionFactory->start(_instance->threadPerConnectionStackSize()); } @@ -869,9 +859,17 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance } _state = StateClosed; + try + { + _acceptor->close(); + } + catch(const LocalException& ex) + { + // Here we ignore any exceptions in close(). + } _acceptor = 0; _threadPerIncomingConnectionFactory = 0; - + __setNoDelete(false); throw; } @@ -977,7 +975,7 @@ IceInternal::IncomingConnectionFactory::registerWithPool() if(_acceptor && !_registeredWithPool) { - _threadPool->_register(_acceptor->fd(), this); + dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_acceptor->fd(), this); _registeredWithPool = true; } } @@ -989,7 +987,7 @@ IceInternal::IncomingConnectionFactory::unregisterWithPool() if(_acceptor && _registeredWithPool) { - _threadPool->unregister(_acceptor->fd()); + dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_acceptor->fd()); _registeredWithPool = false; } } @@ -1080,9 +1078,22 @@ IceInternal::IncomingConnectionFactory::run() // // Create a connection object for the connection. // - assert(transceiver); - connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter); - _connections.push_back(connection); + if(transceiver) + { + try + { + connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter); + _connections.push_back(connection); + } + catch(const IceUtil::Exception&) + { + // + // We don't print any errors here, the connection + // constructor is responsible for printing + // the error. + // + } + } } // diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 4ad8dc33354..f3cd6605f49 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -128,7 +128,6 @@ private: const ::Ice::ObjectAdapterPtr _adapter; bool _registeredWithPool; - const IceInternal::ThreadPoolPtr _threadPool; const bool _warn; diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 790a2d33cea..ceebd9e70b3 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -724,11 +724,14 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica setLocator(_instance->referenceFactory()->getDefaultLocator()); } - int size = _instance->properties()->getPropertyAsInt(_name + ".ThreadPool.Size"); - int sizeMax = _instance->properties()->getPropertyAsInt(_name + ".ThreadPool.SizeMax"); - if(size > 0 || sizeMax > 0) + if(!_instance->threadPerConnection()) { - _threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0); + int size = _instance->properties()->getPropertyAsInt(_name + ".ThreadPool.Size"); + int sizeMax = _instance->properties()->getPropertyAsInt(_name + ".ThreadPool.SizeMax"); + if(size > 0 || sizeMax > 0) + { + _threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0); + } } } catch(...) |