summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/OutgoingConnectionFactory.java
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2014-09-27 16:31:46 -0700
committerMatthew Newhook <matthew@zeroc.com>2014-09-27 16:32:21 -0700
commit4951bbabdd6bd33a8e9ca0cdd46aad613a634626 (patch)
tree8634b14a258d2c9cee0e17a12af805e1af3fec76 /java/src/IceInternal/OutgoingConnectionFactory.java
parentFixed deadlock in connection binding code (ICE-5693) (diff)
downloadice-4951bbabdd6bd33a8e9ca0cdd46aad613a634626.tar.bz2
ice-4951bbabdd6bd33a8e9ca0cdd46aad613a634626.tar.xz
ice-4951bbabdd6bd33a8e9ca0cdd46aad613a634626.zip
- begin_ now never interrupts.
- All potentially blocking Ice APIs are interruption points. - Fixes to the incoming/outgoing factories and shutdown procedure - Fixed bug where connect() was from a user thread. - Added lots more tests to the interrupt test suite.
Diffstat (limited to 'java/src/IceInternal/OutgoingConnectionFactory.java')
-rw-r--r--java/src/IceInternal/OutgoingConnectionFactory.java112
1 files changed, 50 insertions, 62 deletions
diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java
index e2182170ffa..534888ec89e 100644
--- a/java/src/IceInternal/OutgoingConnectionFactory.java
+++ b/java/src/IceInternal/OutgoingConnectionFactory.java
@@ -86,88 +86,76 @@ public final class OutgoingConnectionFactory
waitUntilFinished()
throws InterruptedException
{
- try
+ java.util.Map<Connector, java.util.List<Ice.ConnectionI> > connections = null;
+ synchronized(this)
{
- java.util.Map<Connector, java.util.List<Ice.ConnectionI> > connections = null;
- synchronized(this)
+ //
+ // First we wait until the factory is destroyed. We also
+ // wait until there are no pending connections
+ // anymore. Only then we can be sure the _connections
+ // contains all connections.
+ //
+ while(!_destroyed || !_pending.isEmpty() || _pendingConnectCount > 0)
{
- //
- // First we wait until the factory is destroyed. We also
- // wait until there are no pending connections
- // anymore. Only then we can be sure the _connections
- // contains all connections.
- //
- while(!_destroyed || !_pending.isEmpty() || _pendingConnectCount > 0)
- {
- wait();
- }
-
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- connections = new java.util.HashMap<Connector, java.util.List<Ice.ConnectionI> >(_connections);
+ wait();
}
//
- // Now we wait until the destruction of each connection is finished.
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
//
- for(java.util.List<Ice.ConnectionI> connectionList : connections.values())
+ connections = new java.util.HashMap<Connector, java.util.List<Ice.ConnectionI> >(_connections);
+ }
+
+ //
+ // Now we wait until the destruction of each connection is finished.
+ //
+ for(java.util.List<Ice.ConnectionI> connectionList : connections.values())
+ {
+ for(Ice.ConnectionI connection : connectionList)
{
- for(Ice.ConnectionI connection : connectionList)
+ try
{
- try
- {
- connection.waitUntilFinished();
- }
- catch(InterruptedException e)
+ connection.waitUntilFinished();
+ }
+ catch(InterruptedException e)
+ {
+ //
+ // Force close all of the connections.
+ //
+ for(java.util.List<Ice.ConnectionI> l : connections.values())
{
- //
- // Force close all of the connections.
- //
- for(java.util.List<Ice.ConnectionI> l : connections.values())
+ for(Ice.ConnectionI c : l)
{
- for(Ice.ConnectionI c : l)
- {
- c.close(true);
- }
+ c.close(true);
}
- throw e;
}
+ throw e;
}
}
+ }
- synchronized(this)
+ synchronized(this)
+ {
+ // Ensure all the connections are finished and reapable at this point.
+ java.util.List<Ice.ConnectionI> cons = _monitor.swapReapedConnections();
+ if(cons != null)
{
- // Ensure all the connections are finished and reapable at this point.
- java.util.List<Ice.ConnectionI> cons = _monitor.swapReapedConnections();
- if(cons != null)
- {
- int size = 0;
- for(java.util.List<Ice.ConnectionI> connectionList : _connections.values())
- {
- size += connectionList.size();
- }
- assert(cons.size() == size);
- _connections.clear();
- _connectionsByEndpoint.clear();
- }
- else
+ int size = 0;
+ for(java.util.List<Ice.ConnectionI> connectionList : _connections.values())
{
- assert(_connections.isEmpty());
- assert(_connectionsByEndpoint.isEmpty());
+ size += connectionList.size();
}
- _monitor.destroy();
+ assert(cons.size() == size);
+ _connections.clear();
+ _connectionsByEndpoint.clear();
+ }
+ else
+ {
+ assert(_connections.isEmpty());
+ assert(_connectionsByEndpoint.isEmpty());
}
- }
- catch(InterruptedException ex)
- {
- // Here wait() or waitUntilFinished() were interrupted. Clear the connections
- // and such and continue along.
- _connections.clear();
- _connectionsByEndpoint.clear();
_monitor.destroy();
- throw ex;
}
}