Bug 1416084. P2 - wake up readers when download is suspended. draft
authorJW Wang <jwwang@mozilla.com>
Mon, 15 Jan 2018 10:25:11 +0800
changeset 720766 8c9c8ef7277d834f37d6fdb72e8d7075c9863ee2
parent 720765 ff222a284e19b457faf0c547d28571871cbfac0c
child 720804 e14697a1628e71efd2aecad4677830be5f2dc4da
push id95630
push userjwwang@mozilla.com
push dateTue, 16 Jan 2018 07:50:46 +0000
bugs1416084, 1412737
milestone59.0a1
Bug 1416084. P2 - wake up readers when download is suspended. It is possible that download is suspended after all bytes are received but before OnStopRequest is notified. In that case, we will fail to wake up the readers waiting to read the partial block and cause bug 1412737 comment 30. MozReview-Commit-ID: GUk4lXO6Upk
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -2301,16 +2301,21 @@ MediaCacheStream::NotifyClientSuspended(
   nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
     "MediaCacheStream::NotifyClientSuspended", [client, this, aSuspended]() {
       AutoLock lock(mMediaCache->Monitor());
       if (!mClosed && mClientSuspended != aSuspended) {
         mClientSuspended = aSuspended;
         // mClientSuspended changes the decision of reading streams.
         mMediaCache->QueueUpdate(lock);
         UpdateDownloadStatistics(lock);
+        if (mClientSuspended) {
+          // Download is suspended. Wake up the readers that might be able to
+          // get data from the partial block.
+          lock.NotifyAll();
+        }
       }
     });
   OwnerThread()->Dispatch(r.forget());
 }
 
 void
 MediaCacheStream::NotifyResume()
 {