diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-05-02 08:28:01 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-05-02 08:28:01 +0200 |
commit | 0760fea585122ad26bc7c18941fc67eb187291b0 (patch) | |
tree | cfacec796c5026bde0ca35bdecc3474ae78cdfef /js | |
parent | Fixed bug where connection to SOCKs/HTTP proxies could hang under certain con... (diff) | |
download | ice-0760fea585122ad26bc7c18941fc67eb187291b0.tar.bz2 ice-0760fea585122ad26bc7c18941fc67eb187291b0.tar.xz ice-0760fea585122ad26bc7c18941fc67eb187291b0.zip |
Fix to no longer recursively try endpoints on connection establishment
Diffstat (limited to 'js')
-rw-r--r-- | js/src/Ice/OutgoingConnectionFactory.js | 121 |
1 files changed, 67 insertions, 54 deletions
diff --git a/js/src/Ice/OutgoingConnectionFactory.js b/js/src/Ice/OutgoingConnectionFactory.js index d2c88846249..12fec6c67e5 100644 --- a/js/src/Ice/OutgoingConnectionFactory.js +++ b/js/src/Ice/OutgoingConnectionFactory.js @@ -807,26 +807,9 @@ var ConnectCallback = Class({ connectionStartFailed: function(connection, ex) { Debug.assert(this._current !== null); - - if(ex instanceof Ice.LocalException) - { - this._factory.handleConnectionException(ex, this._hasMore || this._index < this._endpoints.length); - if(ex instanceof Ice.CommunicatorDestroyedException) // No need to continue. - { - this._factory.finishGetConnectionEx(this._endpoints, ex, this); - } - else if(this._index < this._endpoints.length) // Try the next endpoint. - { - this.nextEndpoint(); - } - else - { - this._factory.finishGetConnectionEx(this._endpoints, ex, this); - } - } - else + if(this.connectionStartFailedImpl(ex)) { - this._factory.finishGetConnectionEx(this._endpoints, ex, this); + this.nextEndpoint(); } }, setConnection: function(connection, compress) @@ -929,50 +912,80 @@ var ConnectCallback = Class({ }, nextEndpoint: function() { - var connection = null; - var traceLevels = this._factory._instance.traceLevels(); - try + while(true) { - Debug.assert(this._index < this._endpoints.length); - this._current = this._endpoints[this._index++]; - - if(traceLevels.network >= 2) + var traceLevels = this._factory._instance.traceLevels(); + try { - var s = []; - s.push("trying to establish "); - s.push(this._current.protocol()); - s.push(" connection to "); - s.push(this._current.toConnectorString()); - this._factory._instance.initializationData().logger.trace(traceLevels.networkCat, s.join("")); - } + Debug.assert(this._index < this._endpoints.length); + this._current = this._endpoints[this._index++]; - connection = this._factory.createConnection(this._current.connect(), this._current); - var self = this; - connection.start().then( - function() + if(traceLevels.network >= 2) { - self.connectionStartCompleted(connection); - }, - function(ex) + var s = []; + s.push("trying to establish "); + s.push(this._current.protocol()); + s.push(" connection to "); + s.push(this._current.toConnectorString()); + this._factory._instance.initializationData().logger.trace(traceLevels.networkCat, s.join("")); + } + + var connection = this._factory.createConnection(this._current.connect(), this._current); + var self = this; + connection.start().then( + function() + { + self.connectionStartCompleted(connection); + }, + function(ex) + { + self.connectionStartFailed(connection, ex); + }); + } + catch(ex) + { + if(traceLevels.network >= 2) + { + var s = []; + s.push("failed to establish "); + s.push(this._current.protocol()); + s.push(" connection to "); + s.push(this._current.toString()); + s.push("\n"); + s.push(ex.toString()); + this._factory._instance.initializationData().logger.trace(traceLevels.networkCat, s.join("")); + } + + if(this.connectionStartFailedImpl(ex)) { - self.connectionStartFailed(connection, ex); - }); + continue; + } + } + break; } - catch(ex) + }, + connectionStartFailedImpl: function(ex) + { + if(ex instanceof Ice.LocalException) { - if(traceLevels.network >= 2) + this._factory.handleConnectionException(ex, this._hasMore || this._index < this._endpoints.length); + if(ex instanceof Ice.CommunicatorDestroyedException) // No need to continue. { - var s = []; - s.push("failed to establish "); - s.push(this._current.protocol()); - s.push(" connection to "); - s.push(this._current.toString()); - s.push("\n"); - s.push(ex.toString()); - this._factory._instance.initializationData().logger.trace(traceLevels.networkCat, s.join("")); + this._factory.finishGetConnectionEx(this._endpoints, ex, this); } - - this.connectionStartFailed(connection, ex); + else if(this._index < this._endpoints.length) // Try the next endpoint. + { + return true; + } + else + { + this._factory.finishGetConnectionEx(this._endpoints, ex, this); + } + } + else + { + this._factory.finishGetConnectionEx(this._endpoints, ex, this); } + return false; } }); |