From 24876b7912900e8c5e7d1701ca78aebce0f3f038 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 26 Aug 2021 11:41:16 -0400 Subject: [PATCH] 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 --- base/stream.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/base/stream.jl b/base/stream.jl index 6e433b771f0d2..f4bd8b29fc981 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -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 @@ -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