Bug 1139751 - Fix aborted-session saves that can race to after the shutdown aborted-session removal. r=vladan
☠☠ backed out by a0fae9f2db9b ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Fri, 27 Mar 2015 21:01:20 +0100
changeset 265055 4d163f1939b512490f4b86f6f3dd426f9a554f35
parent 265054 e0ed9413cc171f1cb5c99b20e7d14b5d99cde940
child 265056 54b1d2a173ef406c98c89f5228e84d4a0b045ef2
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs1139751
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1139751 - Fix aborted-session saves that can race to after the shutdown aborted-session removal. r=vladan
toolkit/components/telemetry/TelemetrySession.jsm
--- a/toolkit/components/telemetry/TelemetrySession.jsm
+++ b/toolkit/components/telemetry/TelemetrySession.jsm
@@ -1982,17 +1982,18 @@ let Impl = {
       addClientId: true,
       addEnvironment: true,
     };
 
     let promise = TelemetryPing.send(getPingType(payload), payload, options);
 #if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID)
     // If required, also save the payload as an aborted session.
     if (saveAsAborted) {
-      return promise.then(() => this._saveAbortedSessionPing(payload));
+      let abortedPromise = this._saveAbortedSessionPing(payload);
+      promise = promise.then(() => abortedPromise);
     }
 #endif
     return promise;
   },
 
   /**
    * Loads session data from the session data file.
    * @return {Promise<boolean>} A promise which is resolved with a true argument when
@@ -2089,18 +2090,23 @@ let Impl = {
    * Deletes the aborted session ping. This is called during shutdown.
    * @return {Promise} Resolved when the aborted session ping is removed or if it doesn't
    *                   exist.
    */
   _removeAbortedSessionPing: function() {
     const FILE_PATH = OS.Path.join(OS.Constants.Path.profileDir, DATAREPORTING_DIRECTORY,
                                    ABORTED_SESSION_FILE_NAME);
     try {
+      this._log.trace("_removeAbortedSessionPing - success");
       return OS.File.remove(FILE_PATH);
-    } catch (ex if ex.becauseNoSuchFile) { }
+    } catch (ex if ex.becauseNoSuchFile) {
+      this._log.trace("_removeAbortedSessionPing - no such file");
+    } catch (ex) {
+      this._log.error("_removeAbortedSessionPing - error removing ping", ex)
+    }
     return Promise.resolve();
   },
 
   /**
    * Check if there's any aborted session ping available. If so, tell TelemetryPing about
    * it.
    */
   _checkAbortedSessionPing: Task.async(function* () {