Bug 986762: don't release DataChannelConnection on transient thread on readblob failure r=smaug

This commit is contained in:
Randell Jesup 2014-03-23 14:52:02 -04:00
parent dffeca26fa
commit 9f058b2c24

View File

@ -2338,18 +2338,17 @@ DataChannelConnection::ReadBlob(already_AddRefed<DataChannelConnection> aThis,
// be deferred until buffer space is available.
nsCString temp;
uint64_t len;
aBlob->Available(&len);
nsresult rv = NS_ReadInputStreamToString(aBlob, temp, len);
if (NS_FAILED(rv)) {
nsCOMPtr<nsIThread> mainThread;
NS_GetMainThread(getter_AddRefs(mainThread));
if (NS_FAILED(aBlob->Available(&len)) ||
NS_FAILED(NS_ReadInputStreamToString(aBlob, temp, len))) {
// Bug 966602: Doesn't return an error to the caller via onerror.
// Let aThis (aka this) be released when we exit out of paranoia
// instead of calling Release()
nsRefPtr<DataChannelConnection> self(aThis);
// We must release DataChannelConnection on MainThread to avoid issues (bug 876167)
NS_ProxyRelease(mainThread, aThis.take());
return;
}
aBlob->Close();
nsCOMPtr<nsIThread> mainThread;
NS_GetMainThread(getter_AddRefs(mainThread));
RUN_ON_THREAD(mainThread, WrapRunnable(nsRefPtr<DataChannelConnection>(aThis),
&DataChannelConnection::SendBinaryMsg,
aStream, temp),