Bug 1422545 - Do not close connection between a httpChannelChild and its httpChannelParent if we need to divert to parent. r=mayhemer, a=jcristau
authorDragana Damjanovic <dd.mozilla@gmail.com>
Wed, 20 Dec 2017 16:13:36 +0100
changeset 442996 e7e0bfcbc0404e00ceb94b8533943aec518a60b8
parent 442995 0ef7163b1248c561490ae595c8ee7a9d997c5a7f
child 442997 eb337710c5ffa9c9ea233503a8340b8f44444d2c
push id8420
push userryanvm@gmail.com
push dateThu, 21 Dec 2017 19:17:18 +0000
treeherdermozilla-beta@e7e0bfcbc040 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer, jcristau
bugs1422545
milestone58.0
Bug 1422545 - Do not close connection between a httpChannelChild and its httpChannelParent if we need to divert to parent. r=mayhemer, a=jcristau If UnknowDecoder is involved and the received content is short we will know whether we need to divert to parent only after OnStartRequest of the listener chain is called. Therefore do not do cleanup if we detect diversion.
netwerk/protocol/http/HttpChannelChild.cpp
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -1095,16 +1095,29 @@ HttpChannelChild::OnStopRequest(const ns
     // (although we really shouldn't receive any msgs after OnStop),
     // so make sure this goes out of scope before then.
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
 
     DoOnStopRequest(this, channelStatus, mListenerContext);
     // DoOnStopRequest() calls ReleaseListeners()
   }
 
+  // If unknownDecoder is involved and the received content is short we will
+  // know whether we need to divert to parent only after OnStopRequest of the
+  // listeners chain is called in DoOnStopRequest. At that moment
+  // unknownDecoder will call OnStartRequest of the real listeners of the
+  // channel including the OnStopRequest of UrlLoader which decides whether we
+  // need to divert to parent.
+  // If we are diverting to parent we should not do a cleanup.
+  if (mDivertingToParent) {
+    LOG(("HttpChannelChild::OnStopRequest  - We are diverting to parent, "
+         "postpone cleaning up."));
+    return;
+  }
+
   CleanupBackgroundChannel();
 
   // If there is a possibility we might want to write alt data to the cache
   // entry, we keep the channel alive. We still send the DocumentChannelCleanup
   // message but request the cache entry to be kept by the parent.
   if (!mPreferredCachedAltDataType.IsEmpty()) {
     mKeptAlive = true;
     SendDocumentChannelCleanup(false); // don't clear cache entry