Bug 1026580 - Remove an infinite loop possibility from AsyncTransactionTracker::WaitComplete() r=nical

This commit is contained in:
Sotaro Ikeda 2014-06-21 08:30:30 -07:00
parent e5f6b8cedc
commit 40addacbce

View File

@ -33,16 +33,21 @@ AsyncTransactionTracker::WaitComplete()
MonitorAutoLock mon(mCompletedMonitor);
int count = 0;
while (!mCompleted) {
const int maxCount = 5;
while (!mCompleted && (count < maxCount)) {
if (!NS_SUCCEEDED(mCompletedMonitor.Wait(PR_MillisecondsToInterval(10000)))) {
NS_WARNING("Failed to wait Monitor");
return;
}
if (count > 1) {
NS_WARNING("Waiting async transaction complete.");
printf_stderr("Waiting async transaction complete.\n");
}
count++;
}
if (!mCompleted) {
printf_stderr("Timeout of waiting transaction complete.");
}
}
void