Bug 1450302 - nsInputStreamPump should interrupt the reading of the inputStream when suspended, r=michal
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 05 May 2018 22:58:43 +0200
changeset 473187 698ab4eff5bf1efb1af8ea74e0a8f4f2f906e5ae
parent 473179 1b2650f9cc81613012d0221b8f596289bda09652
child 473188 8afdec869f98a768f1475ad6d0bad70b16c68442
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1450302
milestone61.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 1450302 - nsInputStreamPump should interrupt the reading of the inputStream when suspended, r=michal
netwerk/base/nsInputStreamPump.cpp
--- a/netwerk/base/nsInputStreamPump.cpp
+++ b/netwerk/base/nsInputStreamPump.cpp
@@ -456,29 +456,27 @@ nsInputStreamPump::OnInputStreamReady(ns
         if (nextState == STATE_STOP && !NS_IsMainThread()) {
             mRetargeting = true;
         }
 
         // Unset mProcessingCallbacks here (while we have lock) so our own call to
         // EnsureWaiting isn't blocked by it.
         mProcessingCallbacks = false;
 
-        // We must break the loop when we're switching event delivery to another
-        // thread and the input stream pump is suspended, otherwise
-        // OnStateStop() might be called off the main thread. See bug 1026951
-        // comment #107 for the exact scenario.
-        if (mSuspendCount && mRetargeting) {
+        // We must break the loop if suspended during one of the previous
+        // operation.
+        if (mSuspendCount) {
             mState = nextState;
             mWaitingForInputStreamReady = false;
             break;
         }
 
         // Wait asynchronously if there is still data to transfer, or we're
         // switching event delivery to another thread.
-        if (!mSuspendCount && (stillTransferring || mRetargeting)) {
+        if (stillTransferring || mRetargeting) {
             mState = nextState;
             mWaitingForInputStreamReady = false;
             nsresult rv = EnsureWaiting();
             if (NS_SUCCEEDED(rv))
                 break;
 
             // Failure to start asynchronous wait: stop transfer.
             // Do not set mStatus if it was previously set to report a failure.
@@ -621,17 +619,17 @@ nsInputStreamPump::OnStateTransfer()
                 }
             }
             else
                 mStreamOffset += odaAvail; // assume ODA behaved well
         }
     }
 
     // an error returned from Available or OnDataAvailable should cause us to
-    // abort; however, we must not stomp on mStatus if already canceled.
+    // abort; however, we must not stop on mStatus if already canceled.
 
     if (NS_SUCCEEDED(mStatus)) {
         if (NS_FAILED(rv))
             mStatus = rv;
         else if (avail) {
             // if stream is now closed, advance to STATE_STOP right away.
             // Available may return 0 bytes available at the moment; that
             // would not mean that we are done.