Review 371e60b17c and apply fixes
This commit is contained in:
parent
1eef0ec19c
commit
94fa3fab8c
2 changed files with 6 additions and 7 deletions
|
|
@ -808,13 +808,10 @@ template readIntoExImpl(s: InputStream,
|
|||
let totalBytesDrained = drainBuffersInto(s, dst, dstLen)
|
||||
var bytesDeficit = (dstLen - totalBytesDrained)
|
||||
|
||||
if bytesDeficit > 0:
|
||||
if bytesDeficit > 0 and s.vtable != nil:
|
||||
var adjustedDst = offset(dst, totalBytesDrained)
|
||||
|
||||
while true:
|
||||
if s.vtable.isNil():
|
||||
break
|
||||
|
||||
let newBytesRead = awaiter s.vtable.readOp(s, adjustedDst, bytesDeficit)
|
||||
|
||||
s.spanEndPos += newBytesRead
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@ proc repeat(b: byte, count: int): seq[byte] =
|
|||
result = newSeq[byte](count)
|
||||
for i in 0 ..< count: result[i] = b
|
||||
|
||||
const line = "123456789123456789123456789123456789\n\n\n\n\n"
|
||||
|
||||
proc randomBytes(n: int): seq[byte] =
|
||||
result.newSeq n
|
||||
for i in 0 ..< n:
|
||||
result[i] = byte(rand(int('1')..int('9')))
|
||||
result[i] = byte(rand(line))
|
||||
|
||||
proc readAllAndClose(s: InputStream): seq[byte] =
|
||||
while s.readable:
|
||||
|
|
@ -53,8 +55,8 @@ suite "output stream":
|
|||
streamWritingToExistingBuffer = unsafeMemoryOutput(buffer, bufferSize)
|
||||
|
||||
teardown:
|
||||
fileStream.close()
|
||||
unbufferedFileStream.close()
|
||||
close fileStream
|
||||
close unbufferedFileStream
|
||||
removeFile fileOutputPath
|
||||
removeFile unbufferedFileOutputPath
|
||||
dealloc buffer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue