Skip to content

Commit

Permalink
streams: disable half-duplex operation support (JuliaLang#42005)
Browse files Browse the repository at this point in the history
A stream can continue to be read after closewrite,
but cannot continue to be written to after seeing EOF.

Replaces JuliaLang#42004
Replaces JuliaLang#41983
Fixes JuliaLang#41942
Refs JuliaLang#40783
  • Loading branch information
vtjnash authored and LilithHafner committed Feb 22, 2022
1 parent 1612c39 commit e2e50ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,9 @@ function shutdown(s::LibuvStream)
end
iolock_end()
unpreserve_handle(ct)
if isopen(s) && (s.status == StatusEOF && !isa(s, TTY)) || ccall(:uv_is_readable, Cint, (Ptr{Cvoid},), s.handle) == 0
end
if isopen(s)
if status < 0 || ccall(:uv_is_readable, Cint, (Ptr{Cvoid},), s.handle) == 0
close(s)
end
end
Expand Down Expand Up @@ -658,9 +660,9 @@ function uv_readcb(handle::Ptr{Cvoid}, nread::Cssize_t, buf::Ptr{Cvoid})
notify(stream.cond)
elseif nread == UV_EOF # libuv called uv_stop_reading already
if stream.status != StatusClosing
if stream isa TTY || ccall(:uv_is_writable, Cint, (Ptr{Cvoid},), stream.handle) != 0
# stream can still be used either by reseteof or write
stream.status = StatusEOF
stream.status = StatusEOF
if stream isa TTY # TODO: || ccall(:uv_is_writable, Cint, (Ptr{Cvoid},), stream.handle) != 0
# stream can still be used either by reseteof # TODO: or write
notify(stream.cond)
else
# underlying stream is no longer useful: begin finalization
Expand Down

0 comments on commit e2e50ca

Please sign in to comment.