Bug 1173709 - TelemetrySend.jsm should not wait on sending pings during |setup|. r=gfritzsche
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Fri, 12 Jun 2015 06:39:00 +0200
changeset 279719 a8a08a33b4bf153f0aa11931f2db0ef1903773a2
parent 279718 b3db91f3be69378df491b8e7ad4ae4f4ab8cf74c
child 279720 cc9acd02073ce768db4eb7d5124f5d7199ade689
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1173709
milestone41.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 1173709 - TelemetrySend.jsm should not wait on sending pings during |setup|. r=gfritzsche
toolkit/components/telemetry/TelemetryController.jsm
toolkit/components/telemetry/TelemetrySend.jsm
--- a/toolkit/components/telemetry/TelemetryController.jsm
+++ b/toolkit/components/telemetry/TelemetryController.jsm
@@ -715,22 +715,22 @@ let Impl = {
     if (!this._initialized) {
       return;
     }
 
     Preferences.ignore(PREF_BRANCH_LOG, configureLogging);
 
     // Now do an orderly shutdown.
     try {
+      // Stop any ping sending.
+      yield TelemetrySend.shutdown();
+
       // First wait for clients processing shutdown.
       yield this._shutdownBarrier.wait();
 
-      // Stop any ping sending.
-      yield TelemetrySend.shutdown();
-
       // ... and wait for any outstanding async ping activity.
       yield this._connectionsBarrier.wait();
 
       // Perform final shutdown operations.
       yield TelemetryStorage.shutdown();
     } finally {
       // Reset state.
       this._initialized = false;
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -258,23 +258,31 @@ let TelemetrySendImpl = {
     this._discardedPingsCount = 0;
     this._evictedPingsCount = 0;
 
     Services.obs.addObserver(this, TOPIC_IDLE_DAILY, false);
 
     this._server = Preferences.get(PREF_SERVER, undefined);
 
     // If any pings were submitted before the delayed init finished
-    // we will send them now.
-    yield this._sendPersistedPings();
+    // we will send them now. We don't wait on sending as this could take some time.
+    this._sendPersistedPings();
 
     // Check the pending pings on disk now.
-    yield this._checkPendingPings();
+    let haveOverduePings = yield this._checkPendingPings();
+    if (haveOverduePings) {
+      // We don't wait on sending as this could take some time.
+      this._sendPersistedPings();
+    }
   }),
 
+  /**
+   * Discard old pings from the pending pings and detect overdue ones.
+   * @return {Boolean} True if we have overdue pings, false otherwise.
+   */
   _checkPendingPings: Task.async(function*() {
     // Scan the pending pings - that gives us a list sorted by last modified, descending.
     let infos = yield TelemetryStorage.loadPendingPingList();
     this._log.info("_checkPendingPings - pending ping count: " + infos.length);
     if (infos.length == 0) {
       this._log.trace("_checkPendingPings - no pending pings");
       return;
     }
@@ -314,23 +322,24 @@ let TelemetrySendImpl = {
     Services.telemetry.getHistogramById('TELEMETRY_FILES_EVICTED')
                       .add(evictedCount);
 
     // Check for overdue pings.
     const overduePings = infos.filter((info) =>
       (now.getTime() - info.lastModificationDate) > OVERDUE_PING_FILE_AGE);
     this._overduePingCount = overduePings.length;
 
-
     if (overduePings.length > 0) {
       this._log.trace("_checkForOverduePings - Have " + overduePings.length +
-                       " overdue pending pings, sending " + infos.length +
+                       " overdue pending pings, ready to send " + infos.length +
                        " pings now.");
-      yield this._sendPersistedPings();
+      return true;
     }
+
+    return false;
    }),
 
   shutdown: Task.async(function*() {
     for (let topic of this.OBSERVER_TOPICS) {
       Services.obs.removeObserver(this, topic);
     }
 
     // We can't send anymore now.