# HG changeset patch
# User Dragana Damjanovic
# Parent a235bf4868ab9e48c7b2f4bf4cc9bd949ca23c35
Bug 1422545 - Do not close connection between a httpChannelChild and its httpChannelParent if we need to divert to parent.r=mayhemer
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.
diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/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 the channel has failed, the cache entry is in a non-writtable state and
// we want to release it to not block following consumers.
if (NS_SUCCEEDED(channelStatus) && !mPreferredCachedAltDataType.IsEmpty()) {