Bug 1433855 - Make sure plugin function broker's PostToDispatchThread is Waiting before Notifying it. r=jimm

The Monitor's condition variable could be notified before the calling thread had begun to Wait for it.  This caused the Notify to be missed, leading to hangs.  By grabbing the Monitor in PostToDispatchHelper, we know Wait has been called because, otherwise, the calling thread would still hold the Monitor.
This commit is contained in:
David Parks 2018-01-30 17:32:27 -08:00
Родитель 67e80b725b
Коммит c6dc5f3406
1 изменённых файлов: 6 добавлений и 0 удалений

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

@ -1269,6 +1269,12 @@ protected:
// Note: p is also non-null... its just hard to assert that. // Note: p is also non-null... its just hard to assert that.
MOZ_ASSERT(bmhi && monitor && ok && winErr && r); MOZ_ASSERT(bmhi && monitor && ok && winErr && r);
*ok = bmhi->BrokerCallClient(*winErr, *r, *p...); *ok = bmhi->BrokerCallClient(*winErr, *r, *p...);
{
// By grabbing (and freeing) the lock, we make sure that Wait() has been
// called in PostToDispatchThread. We need that since we wake it with
// Notify().
MonitorAutoLock lock(*monitor);
}
*ok &= NS_SUCCEEDED(monitor->Notify()); *ok &= NS_SUCCEEDED(monitor->Notify());
}; };