IOOperation::Finish():
* Fixed the read with bounce buffer case. When skipping a partial bounce buffer before the part we're interested in, we forgot to update "offset". * Added some more comments for readability. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29999 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -246,9 +246,12 @@ IOOperation::Finish()
|
|||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
|
// We iterate through the vecs we have read, moving offset (the device
|
||||||
|
// offset) as we go. If [offset, offset + vec.iov_len) intersects with
|
||||||
|
// [startOffset, endOffset) we copy to the final location.
|
||||||
off_t offset = fOffset;
|
off_t offset = fOffset;
|
||||||
off_t startOffset = fOriginalOffset;
|
const off_t startOffset = fOriginalOffset;
|
||||||
off_t endOffset = fOriginalOffset + fOriginalLength;
|
const off_t endOffset = fOriginalOffset + fOriginalLength;
|
||||||
|
|
||||||
for (uint32 i = 0; error == B_OK && i < vecCount; i++) {
|
for (uint32 i = 0; error == B_OK && i < vecCount; i++) {
|
||||||
const iovec& vec = vecs[i];
|
const iovec& vec = vecs[i];
|
||||||
@@ -256,21 +259,28 @@ IOOperation::Finish()
|
|||||||
size_t length = vec.iov_len;
|
size_t length = vec.iov_len;
|
||||||
|
|
||||||
if (offset < startOffset) {
|
if (offset < startOffset) {
|
||||||
|
// If the complete vector is before the start offset, skip it.
|
||||||
if (offset + length <= startOffset) {
|
if (offset + length <= startOffset) {
|
||||||
offset += length;
|
offset += length;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The vector starts before the start offset, but intersects
|
||||||
|
// with it. Skip the part we aren't interested in.
|
||||||
size_t diff = startOffset - offset;
|
size_t diff = startOffset - offset;
|
||||||
|
offset += diff;
|
||||||
base += diff;
|
base += diff;
|
||||||
length -= diff;
|
length -= diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + length > endOffset) {
|
if (offset + length > endOffset) {
|
||||||
|
// If we're already beyond the end offset, we're done.
|
||||||
if (offset >= endOffset)
|
if (offset >= endOffset)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// The vector extends beyond the end offset -- cut it.
|
||||||
length = endOffset - offset;
|
length = endOffset - offset;
|
||||||
|
length -= offset + length - endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base >= bounceBufferStart && base < bounceBufferEnd) {
|
if (base >= bounceBufferStart && base < bounceBufferEnd) {
|
||||||
|
|||||||
Reference in New Issue
Block a user