diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-10-13 17:11:49 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-10-13 17:11:49 +0200 |
commit | 2fee4db5224969fc2ad2d0a2594aed126be84ba0 (patch) | |
tree | eb3f8cd0e3525bedf26324db75549a305d42930f /js/src/Ice/RetryQueue.js | |
parent | Fixed (ICE-5709) - IceSSL/configuration failure on Windows (diff) | |
download | ice-2fee4db5224969fc2ad2d0a2594aed126be84ba0.tar.bz2 ice-2fee4db5224969fc2ad2d0a2594aed126be84ba0.tar.xz ice-2fee4db5224969fc2ad2d0a2594aed126be84ba0.zip |
Update JS with the same OutgoingAsync fixes as C++/Java/C#
Diffstat (limited to 'js/src/Ice/RetryQueue.js')
-rw-r--r-- | js/src/Ice/RetryQueue.js | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/js/src/Ice/RetryQueue.js b/js/src/Ice/RetryQueue.js index 5101dbb87fc..86148cd0757 100644 --- a/js/src/Ice/RetryQueue.js +++ b/js/src/Ice/RetryQueue.js @@ -29,6 +29,7 @@ var RetryQueue = Class({ { task.run(); }, interval); + outAsync.__cancelable(task); this._requests.push(task); }, destroy: function() @@ -48,6 +49,16 @@ var RetryQueue = Class({ { this._requests.splice(idx, 1); } + }, + cancel: function(task) + { + var idx = this._requests.indexOf(task); + if(idx >= 0) + { + this._requests.splice(idx, 1); + return this._instance.timer().cancel(task.token); + } + return false; } }); Ice.RetryQueue = RetryQueue; @@ -60,19 +71,32 @@ var RetryTask = Class({ }, run: function() { + this.outAsync.__retry(); + + this.queue.remove(this); + }, + destroy: function() + { try { - this.outAsync.__invoke(); + this.outAsync.__abort(new Ice.CommunicatorDestroyedException()); } catch(ex) { - this.outAsync.__invokeException(ex); + // Abort shouldn't throw if there's no callback, ignore. } - this.queue.remove(this); }, - destroy: function() + asyncRequestCanceled: function(outAsync, ex) { - this.outAsync.__invokeException(new Ice.CommunicatorDestroyedException()); + if(this.queue.cancel(this)) + { + // + // We just retry the outgoing async now rather than marking it + // as finished. The retry will check for the cancellation + // exception and terminate appropriately the request. + // + this.outAsync.__retry(); + } } }); module.exports.Ice = Ice; |