diff options
Diffstat (limited to 'java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java')
-rw-r--r-- | java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java index b73eaa3c251..aa3ed035f46 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java @@ -312,6 +312,8 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // Ignore, could be a class loading error. } + assert(_acceptorStarted); + _acceptorStarted = false; if(_adapter.getThreadPool().finish(this, true)) { closeAcceptor(); @@ -369,13 +371,14 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice { if(_state < StateClosed) { - if(_acceptorStarted && close) + if(close) { closeAcceptor(); } // - // If the acceptor got closed because of an un-expected error, try to restart it in 1 second. + // If the acceptor hasn't been explicitly stopped (which is the case if the acceptor got closed + // because of an unexpected error), try to restart the acceptor in 1 second. // _instance.timer().schedule(new Runnable() { @@ -386,14 +389,13 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice }, 1, java.util.concurrent.TimeUnit.SECONDS); return; } - else if(_state == StateClosed) - { - setState(StateFinished); - if(_acceptorStarted && close) - { - closeAcceptor(); - } + assert(_state == StateClosed); + setState(StateFinished); + + if(close) + { + closeAcceptor(); } } @@ -630,19 +632,24 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice case StateClosed: { - // - // If possible, close the acceptor now to prevent new connections from - // being accepted while we are deactivating. This is especially useful - // if there are no more threads in the thread pool available to dispatch - // the finish() call. - // - if(_adapter.getThreadPool().finish(this, true)) + if(_acceptorStarted) { - if(_acceptorStarted) + // + // If possible, close the acceptor now to prevent new connections from + // being accepted while we are deactivating. This is especially useful + // if there are no more threads in the thread pool available to dispatch + // the finish() call. + // + _acceptorStarted = false; + if(_adapter.getThreadPool().finish(this, true)) { closeAcceptor(); } } + else + { + state = StateFinished; + } for(Ice.ConnectionI connection : _connections) { @@ -724,7 +731,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice _instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.toString()); } - _acceptorStarted = false; + assert(!_acceptorStarted); _acceptor.close(); } |