Bug 1558117 Part 2: Check if other side is closed while state is AboutToWait. r=jrmuizel

If the other side crashed with AboutToWait set in CanvasEventRingBuffer then in
theory we could spin forever waiting for it to change.

Differential Revision: https://phabricator.services.mozilla.com/D61828

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bob Owen 2020-02-24 10:53:43 +00:00
Родитель 6ff3f77570
Коммит d8b69b9e00
1 изменённых файлов: 10 добавлений и 2 удалений

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

@ -232,7 +232,11 @@ void CanvasEventRingBuffer::CheckAndSignalReader() {
return;
case State::AboutToWait:
// The reader is making a decision about whether to wait. So, we must
// wait until it has decided to avoid races.
// wait until it has decided to avoid races. Check if the reader is
// closed to avoid hangs.
if (mWriterServices->ReaderClosed()) {
return;
}
continue;
case State::Waiting:
if (mRead->count != mOurCount) {
@ -347,7 +351,11 @@ void CanvasEventRingBuffer::CheckAndSignalWriter() {
return;
case State::AboutToWait:
// The writer is making a decision about whether to wait. So, we must
// wait until it has decided to avoid races.
// wait until it has decided to avoid races. Check if the writer is
// closed to avoid hangs.
if (mReaderServices->WriterClosed()) {
return;
}
continue;
case State::Waiting:
if (mWrite->count - mOurCount <= mWrite->requiredDifference) {