limit no of retries to prevent infinite loop

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26914 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David McPaul 2008-08-10 13:54:03 +00:00
parent 27c790c14c
commit 086dbe90c8

View File

@ -89,6 +89,8 @@ ChunkCache::NeedsRefill()
status_t
ChunkCache::GetNextChunk(const void **chunkBuffer, size_t *chunkSize, media_header *mediaHeader)
{
uint8 retry_count = 0;
// printf("ChunkCache::GetNextChunk: %p fEmptyChunkCount %ld, fReadyChunkCount %ld\n", fNextGet, fEmptyChunkCount, fReadyChunkCount);
retry:
acquire_sem(fGetWaitSem);
@ -97,6 +99,11 @@ retry:
if (fReadyChunkCount == 0) {
fLocker->Unlock();
printf("ChunkCache::GetNextChunk: %p retrying\n", fNextGet);
// Limit to 5 retries
retry_count++;
if (retry_count > 4) {
return B_ERROR;
}
goto retry;
}
fEmptyChunkCount++;