Bug 1331854 - Spin the event loop instead blocking in RemoteInputStream::ReallyBlockAndWaitForStream, r=bkelly
☠☠ backed out by 8c38fdf34cef ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 20 Jan 2017 08:26:14 +0100
changeset 375278 25c65ac95fc5191ded02ade757f0a3da819266b0
parent 375277 4ec5bc4fff15bf293a7118065df335847d0e2f96
child 375279 7f69f35b4f62db4d3c659103c817c7e9f814d108
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1331854
milestone53.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 1331854 - Spin the event loop instead blocking in RemoteInputStream::ReallyBlockAndWaitForStream, r=bkelly
dom/file/ipc/Blob.cpp
--- a/dom/file/ipc/Blob.cpp
+++ b/dom/file/ipc/Blob.cpp
@@ -1010,22 +1010,30 @@ void
 RemoteInputStream::ReallyBlockAndWaitForStream()
 {
   MOZ_ASSERT(!IsOnOwningThread());
 
   DebugOnly<bool> waited;
 
   {
     MonitorAutoLock lock(mMonitor);
-
     waited = !mStream;
-
-    while (!mStream) {
-      mMonitor.Wait();
+  }
+
+  nsIThread* currentThread = NS_GetCurrentThread();
+  MOZ_ASSERT(currentThread);
+
+  while (true) {
+    {
+      MonitorAutoLock lock(mMonitor);
+      if (mStream) {
+        break;
+      }
     }
+    MOZ_ALWAYS_TRUE(NS_ProcessNextEvent(currentThread));
   }
 
   MOZ_ASSERT(mStream);
 
 #ifdef DEBUG
   if (waited && mWeakSeekableStream) {
     int64_t position;
     if (NS_SUCCEEDED(mWeakSeekableStream->Tell(&position))) {