浏览代码

fix race condition

ericz 12 年之前
父节点
当前提交
317b490811
共有 3 个文件被更改,包括 8 次插入4 次删除
  1. 4 2
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 4 2
      lib/socket.js

+ 4 - 2
dist/peer.js

@@ -1421,8 +1421,10 @@ Socket.prototype._startWebSocket = function() {
   this._socket.onopen = function() {
     if (!!self._timeout) {
       clearTimeout(self._timeout);
-      self._http.abort();
-      self._http = null;
+      setTimeout(function(){
+        self._http.abort();
+        self._http = null;
+      }, 5000);
     }
     util.log('Socket open');
   };

文件差异内容过多而无法显示
+ 0 - 0
dist/peer.min.js


+ 4 - 2
lib/socket.js

@@ -49,8 +49,10 @@ Socket.prototype._startWebSocket = function() {
   this._socket.onopen = function() {
     if (!!self._timeout) {
       clearTimeout(self._timeout);
-      self._http.abort();
-      self._http = null;
+      setTimeout(function(){
+        self._http.abort();
+        self._http = null;
+      }, 5000);
     }
     util.log('Socket open');
   };

部分文件因为文件数量过多而无法显示