Commit 57956152 authored by jaubourg's avatar jaubourg

Removed xhr pooling since failing cross-domain requests leaves the xhr object...

Removed xhr pooling since failing cross-domain requests leaves the xhr object in an undefined state in Firefox. Also rewrote comments related to the active xhr list so that they make sense.
parent 667a3b31
(function( jQuery ) { (function( jQuery ) {
var // Next fake timer id var // Next active xhr id
xhrPollingId = jQuery.now(), xhrId = jQuery.now(),
// Callbacks hashtable // active xhrs
xhrs = {}, xhrs = {},
// XHR pool
xhrPool = [],
// #5280: see below // #5280: see below
xhrUnloadAbortInstalled; xhrUnloadAbortInstalled;
...@@ -42,7 +39,7 @@ jQuery.ajax.transport( function( s , determineDataType ) { ...@@ -42,7 +39,7 @@ jQuery.ajax.transport( function( s , determineDataType ) {
} }
// Get a new xhr // Get a new xhr
var xhr = xhrPool.pop() || s.xhr(), var xhr = s.xhr(),
handle; handle;
// Open the socket // Open the socket
...@@ -74,14 +71,12 @@ jQuery.ajax.transport( function( s , determineDataType ) { ...@@ -74,14 +71,12 @@ jQuery.ajax.transport( function( s , determineDataType ) {
try { try {
xhr.send( ( s.hasContent && s.data ) || null ); xhr.send( ( s.hasContent && s.data ) || null );
} catch(e) { } catch(e) {
// Store back into pool
xhrPool.push( xhr );
complete(0, "error", "" + e); complete(0, "error", "" + e);
return; return;
} }
// Listener // Listener
callback = function( isAbort ) { callback = function( _ , isAbort ) {
// Was never called and is aborted or complete // Was never called and is aborted or complete
if ( callback && ( isAbort || xhr.readyState === 4 ) ) { if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
...@@ -94,8 +89,6 @@ jQuery.ajax.transport( function( s , determineDataType ) { ...@@ -94,8 +89,6 @@ jQuery.ajax.transport( function( s , determineDataType ) {
if (handle) { if (handle) {
xhr.onreadystatechange = jQuery.noop; xhr.onreadystatechange = jQuery.noop;
delete xhrs[ handle ]; delete xhrs[ handle ];
handle = undefined;
xhrPool.push( xhr );
} }
// If it's an abort // If it's an abort
...@@ -171,18 +164,16 @@ jQuery.ajax.transport( function( s , determineDataType ) { ...@@ -171,18 +164,16 @@ jQuery.ajax.transport( function( s , determineDataType ) {
} else { } else {
// Listener is externalized to handle abort on unload // Add to list of active xhrs
handle = xhrPollingId++; handle = xhrId++;
xhrs[ handle ] = xhr; xhrs[ handle ] = xhr;
xhr.onreadystatechange = function() { xhr.onreadystatechange = callback;
callback();
};
} }
}, },
abort: function() { abort: function() {
if ( callback ) { if ( callback ) {
callback(1); callback(0,1);
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment