Bug 1430508: Return 0 for ProcessId() when channel IPC is closed. r=dragana

There are some corner cases where we try to attach StreamFilter endpoints to a
channel after its IPC has been closed from from the other side, but request
listeners haven't been notified. This causes crashes in any of several places.

This patch changes nsHttpChannel::ProcessId to return 0 when IPC is closed, so
callers can detect that it's no longer possible to attach endpoints to it.

MozReview-Commit-ID: BZTOqezih0P

--HG--
extra : rebase_source : dfdb5bf7a11fccea51a1fbb161e688f10167da30
This commit is contained in:
Kris Maglione 2018-01-14 17:40:09 -08:00
Родитель 3a19777b1f
Коммит bef381375c
3 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -265,6 +265,15 @@ HttpChannelParent::CleanupBackgroundChannel()
}
}
base::ProcessId
HttpChannelParent::OtherPid() const
{
if (mIPCClosed) {
return 0;
}
return Manager()->OtherPid();
}
//-----------------------------------------------------------------------------
// HttpChannelParent::nsISupports
//-----------------------------------------------------------------------------

Просмотреть файл

@ -120,6 +120,8 @@ public:
// Callback while background channel is destroyed.
void OnBackgroundParentDestroyed();
base::ProcessId OtherPid() const override;
protected:
// used to connect redirected-to channel in parent with just created
// ChildChannel. Used during redirects.

Просмотреть файл

@ -136,9 +136,12 @@ StreamFilterParent::Create(dom::ContentParent* aContentParent, uint64_t aChannel
RefPtr<nsHttpChannel> chan = do_QueryObject(channel);
NS_ENSURE_TRUE(chan, false);
auto channelPid = chan->ProcessId();
NS_ENSURE_TRUE(channelPid, false);
Endpoint<PStreamFilterParent> parent;
Endpoint<PStreamFilterChild> child;
nsresult rv = PStreamFilter::CreateEndpoints(chan->ProcessId(),
nsresult rv = PStreamFilter::CreateEndpoints(channelPid,
aContentParent ? aContentParent->OtherPid()
: base::GetCurrentProcId(),
&parent, &child);