Skip to content

Commit 24876b7

Browse files
authored
streams: disable half-duplex operation support (#42005)
A stream can continue to be read after closewrite, but cannot continue to be written to after seeing EOF. Replaces #42004 Replaces #41983 Fixes #41942 Refs #40783
1 parent f7506aa commit 24876b7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

base/stream.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ function shutdown(s::LibuvStream)
467467
end
468468
iolock_end()
469469
unpreserve_handle(ct)
470-
if isopen(s) && (s.status == StatusEOF && !isa(s, TTY)) || ccall(:uv_is_readable, Cint, (Ptr{Cvoid},), s.handle) == 0
470+
end
471+
if isopen(s)
472+
if status < 0 || ccall(:uv_is_readable, Cint, (Ptr{Cvoid},), s.handle) == 0
471473
close(s)
472474
end
473475
end
@@ -658,9 +660,9 @@ function uv_readcb(handle::Ptr{Cvoid}, nread::Cssize_t, buf::Ptr{Cvoid})
658660
notify(stream.cond)
659661
elseif nread == UV_EOF # libuv called uv_stop_reading already
660662
if stream.status != StatusClosing
661-
if stream isa TTY || ccall(:uv_is_writable, Cint, (Ptr{Cvoid},), stream.handle) != 0
662-
# stream can still be used either by reseteof or write
663-
stream.status = StatusEOF
663+
stream.status = StatusEOF
664+
if stream isa TTY # TODO: || ccall(:uv_is_writable, Cint, (Ptr{Cvoid},), stream.handle) != 0
665+
# stream can still be used either by reseteof # TODO: or write
664666
notify(stream.cond)
665667
else
666668
# underlying stream is no longer useful: begin finalization

0 commit comments

Comments
 (0)