diff options
author | Marc Laukien <marc@zeroc.com> | 2005-04-11 18:46:36 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2005-04-11 18:46:36 +0000 |
commit | a5c17db709330b05138b4725f82ef8135005cc36 (patch) | |
tree | baaf4d97fe2563029f1d09ed496a68a02a9ddcdb /java/src | |
parent | Fix filesets fro ice-cpp-dev so slice2cpp and slice2freezej are actually (diff) | |
download | ice-a5c17db709330b05138b4725f82ef8135005cc36.tar.bz2 ice-a5c17db709330b05138b4725f82ef8135005cc36.tar.xz ice-a5c17db709330b05138b4725f82ef8135005cc36.zip |
thread per connection fix
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ConnectionI.java | 39 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingConnectionFactory.java | 58 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingConnectionFactory.java | 11 |
3 files changed, 55 insertions, 53 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index 273eea1d60c..94788614aab 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -253,9 +253,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne synchronized(this) { if(_transceiver != null || _dispatchCount != 0 || - (_threadPerConnection != null && - _threadPerConnection != Thread.currentThread() && - _threadPerConnection.isAlive())) + (_threadPerConnection != null && _threadPerConnection.isAlive())) { return false; } @@ -279,14 +277,18 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } - if(threadPerConnection != null && threadPerConnection != Thread.currentThread()) + if(threadPerConnection != null) { - try - { - threadPerConnection.join(); - } - catch(InterruptedException ex) + while(true) { + try + { + threadPerConnection.join(); + break; + } + catch(InterruptedException ex) + { + } } } @@ -401,14 +403,18 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } - if(threadPerConnection != null && threadPerConnection != Thread.currentThread()) + if(threadPerConnection != null) { - try - { - threadPerConnection.join(); - } - catch(InterruptedException ex) + while(true) { + try + { + threadPerConnection.join(); + break; + } + catch(InterruptedException ex) + { + } } } } @@ -1402,7 +1408,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne s += sw.toString(); _instance.logger().error(s); - _state = StateClosed; try { _transceiver.close(); @@ -1411,8 +1416,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { // Here we ignore any exceptions in close(). } - _transceiver = null; - _threadPerConnection = null; Ice.SyscallException e = new Ice.SyscallException(); e.initCause(ex); diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index 8f2e8e97ab1..2b0b88711e0 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -103,15 +103,18 @@ public final class IncomingConnectionFactory extends EventHandler _connections = new java.util.LinkedList(); } - if(threadPerIncomingConnectionFactory != null && - threadPerIncomingConnectionFactory != Thread.currentThread()) + if(threadPerIncomingConnectionFactory != null) { - try - { - threadPerIncomingConnectionFactory.join(); - } - catch(InterruptedException ex) + while(true) { + try + { + threadPerIncomingConnectionFactory.join(); + break; + } + catch(InterruptedException ex) + { + } } } @@ -268,12 +271,6 @@ public final class IncomingConnectionFactory extends EventHandler } catch(Ice.LocalException ex) { - // - // Ignore all exceptions while constructing the - // connection. Warning or error messages for such - // exceptions are printed directly by the - // connection object constructor. - // return; } @@ -302,12 +299,12 @@ public final class IncomingConnectionFactory extends EventHandler } catch(Ice.LocalException ex) { - // - // Ignore all exceptions while validating the - // connection. Warning or error messages for such - // exceptions are printed directly by the validation code. - // - return; + synchronized(this) + { + connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup. + _connections.remove(connection); + return; + } } connection.activate(); @@ -378,7 +375,7 @@ public final class IncomingConnectionFactory extends EventHandler { _endpoint = h.value; - Ice.ConnectionI connection; + Ice.ConnectionI connection = null; try { @@ -388,12 +385,14 @@ public final class IncomingConnectionFactory extends EventHandler catch(Ice.LocalException ex) { // - // Ignore all exceptions while constructing or - // validating the connection. Warning or error - // messages for such exceptions are printed directly - // by the connection object constructor and validation - // code. + // If a connection object was constructed, then + // validate() must have raised the exception. // + if(connection != null) + { + connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup. + } + return; } @@ -432,10 +431,6 @@ public final class IncomingConnectionFactory extends EventHandler // Here we ignore any exceptions in close(). } - _state = StateClosed; - _acceptor = null; - _threadPerIncomingConnectionFactory = null; - Ice.SyscallException e = new Ice.SyscallException(); e.initCause(ex); throw e; @@ -707,11 +702,6 @@ public final class IncomingConnectionFactory extends EventHandler } catch(Ice.LocalException ex) { - // - // We don't print any errors here, the - // connection constructor is responsible for - // printing the error. - // return; } diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index e619b5e0e78..cddf01ea198 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -320,7 +320,16 @@ public final class OutgoingConnectionFactory catch(Ice.LocalException ex) { exception = ex; - connection = null; // Necessary for the case where validate() fails. + + // + // If a connection object was constructed, then validate() + // must have raised the exception. + // + if(connection != null) + { + connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup. + connection = null; + } } TraceLevels traceLevels = _instance.traceLevels(); |