[Pkg-javascript-commits] [sockjs-client] 141/434: Delay sending messages by 25 ms, in order to make tests more stable.
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository sockjs-client.
commit a0b2a18b399247d97404c8a8beda858bb2f548e6
Author: Marek Majkowski <majek04 at gmail.com>
Date: Fri Sep 9 14:21:04 2011 +0100
Delay sending messages by 25 ms, in order to make tests more stable.
---
lib/trans-sender.js | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/lib/trans-sender.js b/lib/trans-sender.js
index cee6b43..8a573e0 100644
--- a/lib/trans-sender.js
+++ b/lib/trans-sender.js
@@ -7,11 +7,32 @@ BufferedSender.prototype.send_constructor = function(sender) {
BufferedSender.prototype.doSend = function(message) {
var that = this;
that.send_buffer.push(message);
- if (typeof that.send_stop === 'undefined') {
+ if (!that.send_stop) {
that.send_schedule();
}
};
+// For polling transports in a situation when in the message callback,
+// new message is being send. If the sending connection was started
+// before receiving one, it is possible to saturate the network and
+// timeout due to the lack of receiving socket. To avoid that we delay
+// sending messages by some small time, in order to let receiving
+// connection be started beforehand. This is only a halfmeasure and
+// does not fix the big problem, but it does make the tests go more
+// stable on slow networks.
+BufferedSender.prototype.send_schedule_wait = function() {
+ var that = this;
+ var tref;
+ that.send_stop = function() {
+ that.send_stop = null;
+ clearTimeout(tref);
+ };
+ tref = utils.delay(25, function() {
+ that.send_stop = null;
+ that.send_schedule();
+ });
+};
+
BufferedSender.prototype.send_schedule = function() {
var that = this;
if (that.send_buffer.length > 0) {
@@ -19,8 +40,8 @@ BufferedSender.prototype.send_schedule = function() {
that.send_stop = that.sender(that.trans_url,
payload,
function() {
- that.send_stop = undefined;
- that.send_schedule();
+ that.send_stop = null;
+ that.send_schedule_wait();
});
that.send_buffer = [];
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list