[DOM Fetch] Detect broken pipes and propagate that write error to the caller.
This commit is contained in:
parent
7f64e41a8a
commit
42d858513b
|
@ -771,6 +771,17 @@ FetchDriver::OnDataAvailable(nsIRequest* aRequest,
|
||||||
nsresult rv = aInputStream->ReadSegments(NS_CopySegmentToStream,
|
nsresult rv = aInputStream->ReadSegments(NS_CopySegmentToStream,
|
||||||
mPipeOutputStream,
|
mPipeOutputStream,
|
||||||
aCount, &aRead);
|
aCount, &aRead);
|
||||||
|
|
||||||
|
// If no data was read, it's possible the output stream is closed but the
|
||||||
|
// ReadSegments call followed its contract of returning NS_OK despite write
|
||||||
|
// errors. Unfortunately, nsIOutputStream has an ill-conceived contract when
|
||||||
|
// taken together with ReadSegments' contract, because the pipe will just
|
||||||
|
// NS_OK if we try and invoke its Write* functions ourselves with a 0 count.
|
||||||
|
// So we must just assume the pipe is broken.
|
||||||
|
if (aRead == 0 && aCount != 0) {
|
||||||
|
return NS_BASE_STREAM_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue