Bug 794091 - Reorganize OS.File importScripts to avoid talos hangs. r=froydnj
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Thu, 08 Nov 2012 14:35:01 -0500
changeset 117807 93a465ae3e4d054e05dd867e364c43930bde5f94
parent 117806 e9d18da148c5470c8b5a7db0d257a09f3ad5cc24
child 117808 8bdc6ccc3705491adeaeb7d7d3cec439925dd058
push idunknown
push userunknown
push dateunknown
reviewersfroydnj
bugs794091
milestone19.0a1
Bug 794091 - Reorganize OS.File importScripts to avoid talos hangs. r=froydnj
toolkit/components/osfile/osfile.jsm
toolkit/components/osfile/osfile_unix_allthreads.jsm
toolkit/components/osfile/osfile_unix_back.jsm
toolkit/components/osfile/osfile_unix_front.jsm
toolkit/components/osfile/osfile_win_allthreads.jsm
toolkit/components/osfile/osfile_win_back.jsm
toolkit/components/osfile/osfile_win_front.jsm
--- a/toolkit/components/osfile/osfile.jsm
+++ b/toolkit/components/osfile/osfile.jsm
@@ -5,14 +5,31 @@
 /**
  * Common front for various implementations of OS.File
  */
 
 if (typeof Components != "undefined") {
   this.EXPORTED_SYMBOLS = ["OS"];
   Components.utils.import("resource://gre/modules/osfile/osfile_async_front.jsm", this);
 } else {
+  // At this stage, we need to import all sources at once to avoid
+  // a unique failure on tbpl + talos that seems caused by a
+  // what looks like a nested event loop bug (see bug 794091).
 #ifdef XP_WIN
-  importScripts("resource://gre/modules/osfile/osfile_win_front.jsm");
+  importScripts(
+    "resource://gre/modules/osfile/osfile_shared_allthreads.jsm",
+    "resource://gre/modules/osfile/osfile_win_allthreads.jsm",
+    "resource://gre/modules/osfile/ospath_win_back.jsm",
+    "resource://gre/modules/osfile/osfile_win_back.jsm",
+    "resource://gre/modules/osfile/osfile_shared_front.jsm",
+    "resource://gre/modules/osfile/osfile_win_front.jsm"
+  );
 #else
-  importScripts("resource://gre/modules/osfile/osfile_unix_front.jsm");
+  importScripts(
+    "resource://gre/modules/osfile/osfile_shared_allthreads.jsm",
+    "resource://gre/modules/osfile/osfile_unix_allthreads.jsm",
+    "resource://gre/modules/osfile/ospath_unix_back.jsm",
+    "resource://gre/modules/osfile/osfile_unix_back.jsm",
+    "resource://gre/modules/osfile/osfile_shared_front.jsm",
+    "resource://gre/modules/osfile/osfile_unix_front.jsm"
+  );
 #endif
-}
\ No newline at end of file
+}
--- a/toolkit/components/osfile/osfile_unix_allthreads.jsm
+++ b/toolkit/components/osfile/osfile_unix_allthreads.jsm
@@ -17,19 +17,16 @@
  * - opened from a chrome worker through importScripts.
  */
 
 if (typeof Components != "undefined") {
   // Module is opened as a jsm module
   this.EXPORTED_SYMBOLS = ["OS"];
   Components.utils.import("resource://gre/modules/ctypes.jsm");
   Components.utils.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", this);
-} else {
-  // File is included from a chrome worker
-  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
 }
 
 (function(exports) {
   "use strict";
   if (!exports.OS || !exports.OS.Shared) {
     throw new Error("osfile_unix_allthreads.jsm must be loaded after osfile_shared_allthreads.jsm");
   }
   if (exports.OS.Shared.Unix) {
--- a/toolkit/components/osfile/osfile_unix_back.jsm
+++ b/toolkit/components/osfile/osfile_unix_back.jsm
@@ -6,18 +6,16 @@
   if (typeof Components != "undefined") {
     // We do not wish osfile_unix_back.jsm to be used directly as a main thread
     // module yet. When time comes, it will be loaded by a combination of
     // a main thread front-end/worker thread implementation that makes sure
     // that we are not executing synchronous IO code in the main thread.
 
     throw new Error("osfile_unix_back.jsm cannot be used from the main thread yet");
   }
-  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
-  importScripts("resource://gre/modules/osfile/osfile_unix_allthreads.jsm");
   (function(exports) {
      "use strict";
      if (!exports.OS) {
        exports.OS = {};
      }
      if (!exports.OS.Unix) {
        exports.OS.Unix = {};
      }
--- a/toolkit/components/osfile/osfile_unix_front.jsm
+++ b/toolkit/components/osfile/osfile_unix_front.jsm
@@ -11,19 +11,16 @@
 
 {
   if (typeof Components != "undefined") {
     // We do not wish osfile_unix_front.jsm to be used directly as a main thread
     // module yet.
 
     throw new Error("osfile_unix_front.jsm cannot be used from the main thread yet");
   }
-  importScripts("resource://gre/modules/osfile/osfile_unix_back.jsm");
-  importScripts("resource://gre/modules/osfile/ospath_unix_back.jsm");
-  importScripts("resource://gre/modules/osfile/osfile_shared_front.jsm");
   (function(exports) {
      "use strict";
 
      // exports.OS.Unix is created by osfile_unix_back.jsm
      if (exports.OS.File) {
        return; // Avoid double-initialization
      }
      exports.OS.Unix.File._init();
--- a/toolkit/components/osfile/osfile_win_allthreads.jsm
+++ b/toolkit/components/osfile/osfile_win_allthreads.jsm
@@ -17,19 +17,16 @@
  * - opened from a chrome worker through importScripts.
  */
 
 if (typeof Components != "undefined") {
   // Module is opened as a jsm module
   this.EXPORTED_SYMBOLS = ["OS"];
   Components.utils.import("resource://gre/modules/ctypes.jsm");
   Components.utils.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", this);
-} else {
-  // File is included from a chrome worker
-  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
 }
 
 (function(exports) {
   "use strict";
   if (!exports.OS || !exports.OS.Shared) {
     throw new Error("osfile_win_allthreads.jsm must be loaded after osfile_shared_allthreads.jsm");
   }
   if (exports.OS.Shared.Win) {
--- a/toolkit/components/osfile/osfile_win_back.jsm
+++ b/toolkit/components/osfile/osfile_win_back.jsm
@@ -23,18 +23,16 @@
   if (typeof Components != "undefined") {
     // We do not wish osfile_win.jsm to be used directly as a main thread
     // module yet. When time comes, it will be loaded by a combination of
     // a main thread front-end/worker thread implementation that makes sure
     // that we are not executing synchronous IO code in the main thread.
 
     throw new Error("osfile_win.jsm cannot be used from the main thread yet");
   }
-  importScripts("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
-  importScripts("resource://gre/modules/osfile/osfile_win_allthreads.jsm");
 
   (function(exports) {
      "use strict";
      if (!exports.OS) {
        exports.OS = {};
      }
      if (!exports.OS.Win) {
        exports.OS.Win = {};
--- a/toolkit/components/osfile/osfile_win_front.jsm
+++ b/toolkit/components/osfile/osfile_win_front.jsm
@@ -11,20 +11,16 @@
 
 {
   if (typeof Components != "undefined") {
     // We do not wish osfile_win_front.jsm to be used directly as a main thread
     // module yet.
     throw new Error("osfile_win_front.jsm cannot be used from the main thread yet");
   }
 
-  importScripts("resource://gre/modules/osfile/osfile_win_back.jsm");
-  importScripts("resource://gre/modules/osfile/ospath_win_back.jsm");
-  importScripts("resource://gre/modules/osfile/osfile_shared_front.jsm");
-
   (function(exports) {
      "use strict";
 
      // exports.OS.Win is created by osfile_win_back.jsm
      if (exports.OS.File) {
        return; // Avoid double-initialization
      }
      exports.OS.Win.File._init();