AdapterIO: Size could be 0

* Also avoid seeking completely when we are sure
we have to block.
This commit is contained in:
Dario Casalinuovo 2016-06-23 00:26:15 +02:00
parent 6b697577fe
commit bcab157e9d

View File

@ -61,6 +61,8 @@ public:
// block on that.
if (IsMutable())
return B_WOULD_BLOCK;
else if (size == 0)
return B_RESOURCE_UNAVAILABLE;
else
return B_ERROR;
}
@ -319,13 +321,15 @@ BAdapterIO::_EvaluateWait(off_t pos)
status_t err = fBuffer->EvaluatePosition(pos);
if (err != B_RESOURCE_UNAVAILABLE && err != B_OK)
return B_UNSUPPORTED;
if (err == B_RESOURCE_UNAVAILABLE && fBuffer->IsStreaming()
&& fBuffer->IsSeekable()) {
if (SeekRequested(pos) != B_OK)
if (err != B_WOULD_BLOCK) {
if (err != B_RESOURCE_UNAVAILABLE && err != B_OK)
return B_UNSUPPORTED;
if (err == B_RESOURCE_UNAVAILABLE && fBuffer->IsStreaming()
&& fBuffer->IsSeekable()) {
if (SeekRequested(pos) != B_OK)
return B_UNSUPPORTED;
}
}
return fBuffer->WaitForData(pos);