Bug 1139751 - Fix aborted-session saves that can race to after the shutdown aborted-session removal. r=vladan,a=vladan
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 02 Apr 2015 21:33:47 +0200
changeset 267220 daeddcbe4e41803be0cbe7e8ab594741efa8c289
parent 267219 221c6a458a01cdabd477f6f093986a8199c5d3a4
child 267221 9c3834da969ea2513ff8a200b30e8b8e8f3d68f6
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan, vladan
bugs1139751
milestone39.0a2
Bug 1139751 - Fix aborted-session saves that can race to after the shutdown aborted-session removal. r=vladan,a=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* () {