Bug 690170 - Part 2: clean up Resource and friends now we've found the culprit. r=philikon
authorRichard Newman <rnewman@mozilla.com>
Fri, 28 Oct 2011 14:43:18 -0700
changeset 80228 1ddb0f2baa6086670ba460c7775dee1941b4b22b
parent 80227 89ade7d15e049c7d5c5e397244acd36650cef1d5
child 80229 d6945db42cbf943910f1785d63b137357470a4ff
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs690170
milestone10.0a1
Bug 690170 - Part 2: clean up Resource and friends now we've found the culprit. r=philikon
services/sync/modules/resource.js
services/sync/modules/rest.js
--- a/services/sync/modules/resource.js
+++ b/services/sync/modules/resource.js
@@ -533,71 +533,31 @@ ChannelListener.prototype = {
     this._data = '';
     this.delayAbort();
   },
 
   onStopRequest: function Channel_onStopRequest(channel, context, status) {
     // Clear the abort timer now that the channel is done.
     this.abortTimer.clear();
 
-    /**
-     * Shim to help investigate Bug 672878.
-     * We seem to be seeing a situation in which onStopRequest is being called
-     * with a success code, but no mResponseHead yet set (a failure condition).
-     * One possibility, according to bzbarsky, is that the channel status and
-     * the status argument don't match up. This block will log that situation.
-     *
-     * Fetching channel.status should not throw, but if it does requestStatus
-     * will be NS_ERROR_UNEXPECTED, which will cause this method to report
-     * failure.
-     */
-    let requestStatus = Cr.NS_ERROR_UNEXPECTED;
     let statusSuccess = Components.isSuccessCode(status);
-    try {
-      // From nsIRequest.
-      requestStatus = channel.status;
-      this._log.trace("Request status is " + requestStatus);
-    } catch (ex) {
-      this._log.warn("Got exception " + Utils.exceptionStr(ex) +
-                     " fetching channel.status.");
-    }
-    if (statusSuccess && (status != requestStatus)) {
-      this._log.error("Request status " + requestStatus +
-                      " does not match status arg " + status);
-      try {
-        channel.responseStatus;
-      } catch (ex) {
-        this._log.error("... and we got " + Utils.exceptionStr(ex) +
-                        " retrieving responseStatus.");
-      }
-    }
-
-    let requestStatusSuccess = Components.isSuccessCode(requestStatus);
-
     let uri = channel && channel.URI && channel.URI.spec || "<unknown>";
     this._log.trace("Channel for " + channel.requestMethod + " " + uri + ": " +
-                    "isSuccessCode(" + status + ")? " + statusSuccess + ", " +
-                    "isSuccessCode(" + requestStatus + ")? " +
-                    requestStatusSuccess);
+                    "isSuccessCode(" + status + ")? " + statusSuccess);
 
     if (this._data == '') {
       this._data = null;
     }
 
-    // Check both the nsIRequest status and the status we were provided.
-    // If either is unsuccessful, don't take the success branch!
-    //
     // Pass back the failure code and stop execution. Use Components.Exception()
     // instead of Error() so the exception is QI-able and can be passed across
     // XPCOM borders while preserving the status code.
-    if (!statusSuccess || !requestStatusSuccess) {
-      // Pick the code that caused us to fail.
-      let code    = statusSuccess ? requestStatus : status;
-      let message = Components.Exception("", code).name;
-      let error   = Components.Exception(message, code);
+    if (!statusSuccess) {
+      let message = Components.Exception("", status).name;
+      let error   = Components.Exception(message, status);
       this._onComplete(error, undefined, channel);
       return;
     }
 
     this._log.trace("Channel: flags = " + channel.loadFlags +
                     ", URI = " + uri +
                     ", HTTP success? " + channel.requestSucceeded);
     this._onComplete(null, this._data, channel);
--- a/services/sync/modules/rest.js
+++ b/services/sync/modules/rest.js
@@ -407,60 +407,25 @@ RESTRequest.prototype = {
 
     // We don't want to do anything for a request that's already been aborted.
     if (this.status == this.ABORTED) {
       this._log.trace("Not proceeding with onStopRequest, request was aborted.");
       return;
     }
     this.status = this.COMPLETED;
 
-    /**
-     * Shim to help investigate Bug 672878.
-     * We seem to be seeing a situation in which onStopRequest is being called
-     * with a success code, but no mResponseHead yet set (a failure condition).
-     * One possibility, according to bzbarsky, is that the channel status and
-     * the status argument don't match up. This block will log that situation.
-     *
-     * Fetching channel.status should not throw, but if it does requestStatus
-     * will be NS_ERROR_UNEXPECTED, which will cause this method to report
-     * failure.
-     *
-     * This code parallels nearly identical shimming in resource.js.
-     */
-    let requestStatus = Cr.NS_ERROR_UNEXPECTED;
     let statusSuccess = Components.isSuccessCode(statusCode);
-    try {
-      // From nsIRequest.
-      requestStatus = channel.status;
-      this._log.trace("Request status is " + requestStatus);
-    } catch (ex) {
-      this._log.warn("Got exception " + Utils.exceptionStr(ex) +
-                     " fetching channel.status.");
-    }
-    if (statusSuccess && (statusCode != requestStatus)) {
-      this._log.error("Request status " + requestStatus +
-                      " does not match status arg " + statusCode);
-      try {
-        channel.responseStatus;
-      } catch (ex) {
-        this._log.error("... and we got " + Utils.exceptionStr(ex) +
-                        " retrieving responseStatus.");
-      }
-    }
-
-    let requestStatusSuccess = Components.isSuccessCode(requestStatus);
-
     let uri = channel && channel.URI && channel.URI.spec || "<unknown>";
     this._log.trace("Channel for " + channel.requestMethod + " " + uri +
                     " returned status code " + statusCode);
 
     // Throw the failure code and stop execution.  Use Components.Exception()
     // instead of Error() so the exception is QI-able and can be passed across
     // XPCOM borders while preserving the status code.
-    if (!statusSuccess || !requestStatusSuccess) {
+    if (!statusSuccess) {
       let message = Components.Exception("", statusCode).name;
       let error = Components.Exception(message, statusCode);
       this.onComplete(error);
       this.onComplete = this.onProgress = null;
       return;
     }
 
     this._log.debug(this.method + " " + uri + " " + this.response.status);