diff options
Diffstat (limited to 'csharp/src/Ice/ConnectionFactory.cs')
-rw-r--r-- | csharp/src/Ice/ConnectionFactory.cs | 115 |
1 files changed, 65 insertions, 50 deletions
diff --git a/csharp/src/Ice/ConnectionFactory.cs b/csharp/src/Ice/ConnectionFactory.cs index 1c418b84198..d51c4fe06f2 100644 --- a/csharp/src/Ice/ConnectionFactory.cs +++ b/csharp/src/Ice/ConnectionFactory.cs @@ -848,24 +848,10 @@ namespace IceInternal public void connectionStartFailed(Ice.ConnectionI connection, Ice.LocalException ex) { - if(_observer != null) - { - _observer.failed(ex.ice_name()); - _observer.detach(); - } - _factory.handleConnectionException(ex, _hasMore || _iter < _connectors.Count); - if(ex is Ice.CommunicatorDestroyedException) // No need to continue. - { - _factory.finishGetConnection(_connectors, ex, this); - } - else if(_iter < _connectors.Count) // Try the next connector. + if(connectionStartFailedImpl(ex)) { nextConnector(); } - else - { - _factory.finishGetConnection(_connectors, ex, this); - } } // @@ -1023,52 +1009,81 @@ namespace IceInternal internal void nextConnector() { - Ice.ConnectionI connection = null; - try + while(true) { - Debug.Assert(_iter < _connectors.Count); - _current = _connectors[_iter++]; - - Ice.Instrumentation.CommunicatorObserver obsv = _factory._instance.initializationData().observer; - if(obsv != null) + try { - _observer = obsv.getConnectionEstablishmentObserver(_current.endpoint, - _current.connector.ToString()); - if(_observer != null) + Debug.Assert(_iter < _connectors.Count); + _current = _connectors[_iter++]; + + Ice.Instrumentation.CommunicatorObserver obsv = _factory._instance.initializationData().observer; + if(obsv != null) + { + _observer = obsv.getConnectionEstablishmentObserver(_current.endpoint, + _current.connector.ToString()); + if(_observer != null) + { + _observer.attach(); + } + } + + if(_factory._instance.traceLevels().network >= 2) { - _observer.attach(); + StringBuilder s = new StringBuilder("trying to establish "); + s.Append(_current.endpoint.protocol()); + s.Append(" connection to "); + s.Append(_current.connector.ToString()); + _factory._instance.initializationData().logger.trace( + _factory._instance.traceLevels().networkCat, s.ToString()); } - } - if(_factory._instance.traceLevels().network >= 2) + Ice.ConnectionI connection = _factory.createConnection(_current.connector.connect(), _current); + connection.start(this); + } + catch(Ice.LocalException ex) { - StringBuilder s = new StringBuilder("trying to establish "); - s.Append(_current.endpoint.protocol()); - s.Append(" connection to "); - s.Append(_current.connector.ToString()); - _factory._instance.initializationData().logger.trace( - _factory._instance.traceLevels().networkCat, s.ToString()); + if(_factory._instance.traceLevels().network >= 2) + { + StringBuilder s = new StringBuilder("failed to establish "); + s.Append(_current.endpoint.protocol()); + s.Append(" connection to "); + s.Append(_current.connector.ToString()); + s.Append("\n"); + s.Append(ex); + _factory._instance.initializationData().logger.trace( + _factory._instance.traceLevels().networkCat, s.ToString()); + } + + if(connectionStartFailedImpl(ex)) + { + continue; + } } + break; + } + } - connection = _factory.createConnection(_current.connector.connect(), _current); - connection.start(this); + private bool connectionStartFailedImpl(Ice.LocalException ex) + { + if(_observer != null) + { + _observer.failed(ex.ice_name()); + _observer.detach(); } - catch(Ice.LocalException ex) + _factory.handleConnectionException(ex, _hasMore || _iter < _connectors.Count); + if(ex is Ice.CommunicatorDestroyedException) // No need to continue. { - if(_factory._instance.traceLevels().network >= 2) - { - StringBuilder s = new StringBuilder("failed to establish "); - s.Append(_current.endpoint.protocol()); - s.Append(" connection to "); - s.Append(_current.connector.ToString()); - s.Append("\n"); - s.Append(ex); - _factory._instance.initializationData().logger.trace( - _factory._instance.traceLevels().networkCat, s.ToString()); - } - - connectionStartFailed(connection, ex); + _factory.finishGetConnection(_connectors, ex, this); + } + else if(_iter < _connectors.Count) // Try the next connector. + { + return true; } + else + { + _factory.finishGetConnection(_connectors, ex, this); + } + return false; } private OutgoingConnectionFactory _factory; |