USB: Don't loop endlessly waiting for a physical buffer.

This is used quite a lot in critical transfer paths, so we don't
want to lock things up if no buffers are available for whatever reason.
Wait 2 seconds, and if we didn't get anything by then, return B_NO_MEMORY.

Possibly fixes or helps with certain USB-related lockups.
This commit is contained in:
Augustin Cavalier
2019-02-22 13:32:27 -05:00
parent 7b53b3c2e4
commit da8c1a9a40
@@ -222,7 +222,10 @@ PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
TRACE_ERROR(("PMA: found no free slot to store %ld bytes, waiting\n",
size));
entry.Wait();
if (entry.Wait(B_RELATIVE_TIMEOUT, 2 * 1000 * 1000) == B_TIMED_OUT) {
TRACE_ERROR(("PMA: timed out waiting for a free slot, giving up\n"));
break;
}
if (!_Lock())
return B_ERROR;