diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-01-28 08:21:22 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-01-28 08:21:22 +0000 |
commit | ff30351289b99a7b038722db12abdf1d3fac8091 (patch) | |
tree | 8740b808fb7206106ae09f2729cc36f222784245 /java/src | |
parent | The object adapter thread pool is not created anymore if thread per (diff) | |
download | ice-ff30351289b99a7b038722db12abdf1d3fac8091.tar.bz2 ice-ff30351289b99a7b038722db12abdf1d3fac8091.tar.xz ice-ff30351289b99a7b038722db12abdf1d3fac8091.zip |
The object adapter thread pool isn't created anymore if thread per
connection is enabled.
Added more exception and error handling to the IncomingConnectionFactory.
Fixed a bug where the wrong thread pool was used for the
IncomingConnectionFactory.
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 11 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingConnectionFactory.java | 57 |
2 files changed, 38 insertions, 30 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index 37089faf1f8..1e7aaaf1fb7 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -713,11 +713,14 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt 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 IceInternal.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 IceInternal.ThreadPool(_instance, _name + ".ThreadPool", 0); + } } } catch(LocalException ex) diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index d424bbd4351..32063a8cd05 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -390,36 +390,34 @@ public class IncomingConnectionFactory extends EventHandler assert(_acceptor != null); _acceptor.listen(); - 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. - // - _threadPool = ((Ice.ObjectAdapterI)_adapter).getThreadPool(); - } - else + if(_instance.threadPerConnection()) { - // - // If we are in thread per connection mode, we also use - // one thread per incoming connection factory, that - // accepts new connections on this endpoint. - // 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(); _threadPerIncomingConnectionFactory.start(); } catch(RuntimeException ex) { error("cannot create thread for incoming connection factory", ex); - + _state = StateClosed; + try + { + _acceptor.close(); + } + catch(Ice.LocalException e) + { + // Here we ignore any exceptions in close(). + } _acceptor = null; _threadPerIncomingConnectionFactory = null; - + throw ex; } } @@ -552,7 +550,7 @@ public class IncomingConnectionFactory extends EventHandler if(_acceptor != null && !_registeredWithPool) { - _threadPool._register(_acceptor.fd(), this); + ((Ice.ObjectAdapterI)_adapter).getThreadPool()._register(_acceptor.fd(), this); _registeredWithPool = true; } } @@ -564,7 +562,7 @@ public class IncomingConnectionFactory extends EventHandler if(_acceptor != null && _registeredWithPool) { - _threadPool.unregister(_acceptor.fd()); + ((Ice.ObjectAdapterI)_adapter).getThreadPool().unregister(_acceptor.fd()); _registeredWithPool = false; } } @@ -688,13 +686,21 @@ public class IncomingConnectionFactory extends EventHandler // // Create a connection object for the connection. // - // In Java a keyboard interrupt causes accept() to raise a - // SocketException, therefore transceiver may be null. - // if(transceiver != null) { - connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter); - _connections.add(connection); + try + { + connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter); + _connections.add(connection); + } + catch(RuntimeException ex) + { + // + // We don't print any errors here, the + // connection constructor is responsible for + // printing the error. + // + } } } @@ -734,7 +740,6 @@ public class IncomingConnectionFactory extends EventHandler private final Ice.ObjectAdapter _adapter; private boolean _registeredWithPool; - private ThreadPool _threadPool; private final boolean _warn; |