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

make 'read!(::Base.LibuvStream, ::Array{UInt8, 1})' indicate the number of bytes actually received on EOFError #14630

Merged
merged 1 commit into from
Jan 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ function read!(s::LibuvStream, a::Array{UInt8, 1})
finally
s.buffer = sbuf
if !isempty(s.readnotify.waitq)
start_reading(x) # resume reading iff there are currently other read clients of the stream
start_reading(s) # resume reading iff there are currently other read clients of the stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did x come from? seems like like a typo and missing test coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no one having ever seen a UndefVarError or suchlike from here suggests that this branch has very little chance to be executed in concurrency context.

I also suspect that after the stream's buffer has been switched, all other simultaneous pended reads from the same socket that are waiting for the readnotify event in wait_readnb() loop begin to check the loop condition while isopen(x) && nb_available(x.buffer) < nb against the substituted buffer. But when they return from the wait_readnb() and strat copying data (i.e. read!(sbuf, a)) they do it from their saved local reference sbuf rather than from the actual stream's buffer.

end
end
end
Expand Down