summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-07-11 18:17:36 +0200
committerLoïc Hoguin <[email protected]>2012-07-11 18:17:36 +0200
commit8ab7895ce50ec1a66442562d86945fd6000545fd (patch)
treec2213e384acdf4dbd342165adefb11a6f0007bb0
parenta13fd3662ae9e0b9c73a99a3841aaee152987919 (diff)
downloadbullet-8ab7895ce50ec1a66442562d86945fd6000545fd.tar.gz
bullet-8ab7895ce50ec1a66442562d86945fd6000545fd.tar.bz2
bullet-8ab7895ce50ec1a66442562d86945fd6000545fd.zip
Ensure we only handle the onclose event once
Fixes an issue when trying to establish the connection with Firefox 13 fails during the handshake. It would call onclose twice.
-rw-r--r--priv/bullet.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/priv/bullet.js b/priv/bullet.js
index 3a378f6..4ba2cb8 100644
--- a/priv/bullet.js
+++ b/priv/bullet.js
@@ -169,6 +169,7 @@
}
var stream = new function(){
+ var isClosed = true;
var readyState = CLOSED;
var heartbeat;
var delay = delayDefault = 80;
@@ -176,6 +177,7 @@
var transport;
function init(){
+ isClosed = false;
readyState = CONNECTING;
transport = next();
@@ -202,6 +204,12 @@
}
};
transport.onclose = function(){
+ // Firefox 13.0.1 sends 2 close events.
+ // Return directly if we already handled it.
+ if (isClosed){
+ return;
+ }
+
clearInterval(heartbeat);
if (readyState == CLOSING){
@@ -218,6 +226,8 @@
delay = delayMax;
}
+ isClosed = true;
+
setTimeout(function(){
init();
}, delay);