Bug 1539766 - handle the cancel case for e10s bp r=kershaw a=pascalc
authorJunior Hsu <juhsu@mozilla.com>
Wed, 03 Apr 2019 20:35:02 +0000
changeset 526067 8f769d5d958c1681bb88ccd8f080a5d617cd9f95
parent 526066 25fc50452484b96a4a664c779a4222874f3b21de
child 526068 4ec045b28ecc6fb214c80bf8451eced3fc002781
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskershaw, pascalc
bugs1539766
milestone67.0
Bug 1539766 - handle the cancel case for e10s bp r=kershaw a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D25315
netwerk/protocol/http/HttpChannelParent.cpp
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -805,17 +805,30 @@ mozilla::ipc::IPCResult HttpChannelParen
 }
 
 mozilla::ipc::IPCResult HttpChannelParent::RecvCancel(const nsresult& status) {
   LOG(("HttpChannelParent::RecvCancel [this=%p]\n", this));
 
   // May receive cancel before channel has been constructed!
   if (mChannel) {
     mChannel->Cancel(status);
+
+    // Once we receive |Cancel|, child will stop sending RecvBytesRead. Force
+    // the channel resumed if needed.
+    if (mSuspendedForFlowControl) {
+      LOG(("  resume the channel due to e10s backpressure relief by cancel"));
+      Unused << mChannel->Resume();
+      mSuspendedForFlowControl = false;
+    }
   }
+
+  // We won't need flow control anymore. Toggle the flag to avoid |Suspend|
+  // since OnDataAvailable could be off-main-thread.
+  mCacheNeedFlowControlInitialized = true;
+  mNeedFlowControl = false;
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult HttpChannelParent::RecvSetCacheTokenCachedCharset(
     const nsCString& charset) {
   if (mCacheEntry) mCacheEntry->SetMetaDataElement("charset", charset.get());
   return IPC_OK();
 }
@@ -2123,16 +2136,17 @@ nsresult HttpChannelParent::SuspendForDi
 
   rv = mParentListener->SuspendForDiversion();
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 
   // After we suspend for diversion, we don't need the flow control since the
   // channel is suspended until all the data is consumed and no more e10s later.
   // No point to have another redundant suspension.
   if (mSuspendedForFlowControl) {
+    LOG(("  resume the channel due to e10s backpressure relief by diversion"));
     Unused << mChannel->Resume();
     mSuspendedForFlowControl = false;
   }
 
   // Once this is set, no more OnStart/OnData/OnStop callbacks should be sent
   // to the child.
   mDivertingFromChild = true;