Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush buffer to avoid deleting data when seeking NoopStream #172

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented Mar 3, 2024

This fixes one of the broken tests.

This also matches the pattern in unsafe_write where flushbuffer is called before the position in the underlying stream is adjusted if the stream is in :write mode.

function Base.unsafe_write(stream::NoopStream, input::Ptr{UInt8}, nbytes::UInt)
changemode!(stream, :write)
buffer = stream.buffer1
if marginsize(buffer) nbytes
copydata!(buffer, input, nbytes)
return Int(nbytes)
else
flushbuffer(stream)
# directly write data to the underlying stream
return unsafe_write(stream.stream, input, nbytes)
end
end

@nhz2 nhz2 marked this pull request as ready for review March 3, 2024 19:11
@nhz2 nhz2 requested a review from mkitti March 3, 2024 20:29
@nhz2 nhz2 merged commit 4b7f8ad into JuliaIO:master Mar 4, 2024
18 checks passed
@nhz2 nhz2 deleted the nz/flush-before-seek branch March 4, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants