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

Revert "upgrade libuv to v2-1.42.0" and revert "add stream shutdown and support half-duplex operation" #41802

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ endef
COMMA:=,
SPACE:=$(eval) $(eval)

# force a sane / stable configuration
export LC_ALL=C
export LANG=C

# We need python for things like BB triplet recognition and relative path computation.
# We don't really care about version, generally, so just find something that works:
PYTHON := "$(shell which python 2>/dev/null || which python3 2>/dev/null || which python2 2>/dev/null || echo "{python|python3|python2} not found")"
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,3 @@ endif
@time $(call spawn,$(build_bindir)/julia$(EXE) -e '')
@time $(call spawn,$(build_bindir)/julia$(EXE) -e '')
@time $(call spawn,$(build_bindir)/julia$(EXE) -e '')

print-locale:
@locale
1 change: 0 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Standard library changes
overflow in most cases. The new function `checked_length` is now available, which will try to use checked
arithmetic to error if the result may be wrapping. Or use a package such as SaferIntegers.jl when
constructing the range. ([#40382])
* TCP socket objects now expose `shutdown` functionality and support half-open mode usage ([#40783]).

#### InteractiveUtils
* A new macro `@time_imports` for reporting any time spent importing packages and their dependencies ([#41612])
Expand Down
1 change: 0 additions & 1 deletion base/coreio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ write(::DevNull, ::UInt8) = 1
unsafe_write(::DevNull, ::Ptr{UInt8}, n::UInt)::Int = n
close(::DevNull) = nothing
wait_close(::DevNull) = wait()
bytesavailable(io::DevNull) = 0

let CoreIO = Union{Core.CoreSTDOUT, Core.CoreSTDERR}
global write(io::CoreIO, x::UInt8) = Core.write(io, x)
Expand Down
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,6 @@ export

# I/O and events
close,
shutdown,
countlines,
eachline,
readeach,
Expand Down
124 changes: 52 additions & 72 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,49 +60,9 @@ function isopen end
Close an I/O stream. Performs a [`flush`](@ref) first.
"""
function close end

"""
shutdown(stream)

Shutdown the write half of a full-duplex I/O stream. Performs a [`flush`](@ref)
first. Notify the other end that no more data will be written to the underlying
file. This is not supported by all IO types.

# Examples
```jldoctest
julia> io = Base.BufferStream(); # this never blocks, so we can read and write on the same Task

julia> write(io, "request");

julia> # calling `read(io)` here would block forever

julia> shutdown(io);

julia> read(io, String)
"request"
"""
function shutdown end

"""
flush(stream)

Commit all currently buffered writes to the given stream.
"""
function flush end

"""
bytesavailable(io)

Return the number of bytes available for reading before a read from this stream or buffer will block.

# Examples
```jldoctest
julia> io = IOBuffer("JuliaLang is a GitHub organization");

julia> bytesavailable(io)
34
```
"""
function wait_readnb end
function wait_close end
function bytesavailable end

"""
Expand All @@ -121,7 +81,7 @@ function readavailable end
"""
isreadable(io) -> Bool

Return `false` if the specified IO object is not readable.
Return `true` if the specified IO object is readable (if that can be determined).

# Examples
```jldoctest
Expand All @@ -139,12 +99,12 @@ true
julia> rm("myfile.txt")
```
"""
isreadable(io::IO) = isopen(io)
function isreadable end

"""
iswritable(io) -> Bool

Return `false` if the specified IO object is not writable.
Return `true` if the specified IO object is writable (if that can be determined).

# Examples
```jldoctest
Expand All @@ -162,22 +122,9 @@ false
julia> rm("myfile.txt")
```
"""
iswritable(io::IO) = isopen(io)

"""
eof(stream) -> Bool

Test whether an I/O stream is at end-of-file. If the stream is not yet exhausted, this
function will block to wait for more data if necessary, and then return `false`. Therefore
it is always safe to read one byte after seeing `eof` return `false`. `eof` will return
`false` as long as buffered data is still available, even if the remote end of a connection
is closed.
"""
function eof end

function iswritable end
function copy end
function wait_readnb end
function wait_close end
function eof end

"""
read(io::IO, T)
Expand Down Expand Up @@ -410,37 +357,65 @@ end
function pipe_reader end
function pipe_writer end

for f in (:flush, :shutdown, :iswritable)
@eval $(f)(io::AbstractPipe) = $(f)(pipe_writer(io)::IO)
end
write(io::AbstractPipe, byte::UInt8) = write(pipe_writer(io)::IO, byte)
write(to::IO, from::AbstractPipe) = write(to, pipe_reader(from))
unsafe_write(io::AbstractPipe, p::Ptr{UInt8}, nb::UInt) = unsafe_write(pipe_writer(io)::IO, p, nb)::Union{Int,UInt}
buffer_writes(io::AbstractPipe, args...) = buffer_writes(pipe_writer(io)::IO, args...)
flush(io::AbstractPipe) = flush(pipe_writer(io)::IO)

for f in (
# peek/mark interface
:mark, :unmark, :reset, :ismarked,
# Simple reader functions
:read, :readavailable, :bytesavailable, :reseteof, :isreadable)
@eval $(f)(io::AbstractPipe) = $(f)(pipe_reader(io)::IO)
end
read(io::AbstractPipe, byte::Type{UInt8}) = read(pipe_reader(io)::IO, byte)::UInt8
unsafe_read(io::AbstractPipe, p::Ptr{UInt8}, nb::UInt) = unsafe_read(pipe_reader(io)::IO, p, nb)
read(io::AbstractPipe) = read(pipe_reader(io)::IO)
readuntil(io::AbstractPipe, arg::UInt8; kw...) = readuntil(pipe_reader(io)::IO, arg; kw...)
readuntil(io::AbstractPipe, arg::AbstractChar; kw...) = readuntil(pipe_reader(io)::IO, arg; kw...)
readuntil(io::AbstractPipe, arg::AbstractString; kw...) = readuntil(pipe_reader(io)::IO, arg; kw...)
readuntil(io::AbstractPipe, arg::AbstractVector; kw...) = readuntil(pipe_reader(io)::IO, arg; kw...)
readuntil_vector!(io::AbstractPipe, target::AbstractVector, keep::Bool, out) = readuntil_vector!(pipe_reader(io)::IO, target, keep, out)
readbytes!(io::AbstractPipe, target::AbstractVector{UInt8}, n=length(target)) = readbytes!(pipe_reader(io)::IO, target, n)

for f in (
# peek/mark interface
:mark, :unmark, :reset, :ismarked,
# Simple reader functions
:readavailable, :isreadable)
@eval $(f)(io::AbstractPipe) = $(f)(pipe_reader(io)::IO)
end
peek(io::AbstractPipe, ::Type{T}) where {T} = peek(pipe_reader(io)::IO, T)::T
wait_readnb(io::AbstractPipe, nb::Int) = wait_readnb(pipe_reader(io)::IO, nb)
eof(io::AbstractPipe) = eof(pipe_reader(io)::IO)::Bool

iswritable(io::AbstractPipe) = iswritable(pipe_writer(io)::IO)
isopen(io::AbstractPipe) = isopen(pipe_writer(io)::IO) || isopen(pipe_reader(io)::IO)
close(io::AbstractPipe) = (close(pipe_writer(io)::IO); close(pipe_reader(io)::IO))
wait_readnb(io::AbstractPipe, nb::Int) = wait_readnb(pipe_reader(io)::IO, nb)
wait_close(io::AbstractPipe) = (wait_close(pipe_writer(io)::IO); wait_close(pipe_reader(io)::IO))

"""
bytesavailable(io)

Return the number of bytes available for reading before a read from this stream or buffer will block.

# Examples
```jldoctest
julia> io = IOBuffer("JuliaLang is a GitHub organization");

julia> bytesavailable(io)
34
```
"""
bytesavailable(io::AbstractPipe) = bytesavailable(pipe_reader(io)::IO)
bytesavailable(io::DevNull) = 0

"""
eof(stream) -> Bool

Test whether an I/O stream is at end-of-file. If the stream is not yet exhausted, this
function will block to wait for more data if necessary, and then return `false`. Therefore
it is always safe to read one byte after seeing `eof` return `false`. `eof` will return
`false` as long as buffered data is still available, even if the remote end of a connection
is closed.
"""
eof(io::AbstractPipe) = eof(pipe_reader(io)::IO)::Bool
reseteof(io::AbstractPipe) = reseteof(pipe_reader(io)::IO)


# Exception-safe wrappers (io = open(); try f(io) finally close(io))

Expand Down Expand Up @@ -1144,6 +1119,11 @@ ismarked(io::IO) = io.mark >= 0
# Make sure all IO streams support flush, even if only as a no-op,
# to make it easier to write generic I/O code.

"""
flush(stream)

Commit all currently buffered writes to the given stream.
"""
flush(io::IO) = nothing

"""
Expand Down
6 changes: 0 additions & 6 deletions base/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,6 @@ end

eof(io::GenericIOBuffer) = (io.ptr-1 == io.size)

function shutdown(io::GenericIOBuffer)
io.writable = false
# OR throw(_UVError("shutdown", UV_ENOTSOCK))
nothing
end

@noinline function close(io::GenericIOBuffer{T}) where T
io.readable = false
io.writable = false
Expand Down
1 change: 0 additions & 1 deletion base/libuv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ end
function uv_alloc_buf end
function uv_readcb end
function uv_writecb_task end
function uv_shutdowncb_task end
function uv_return_spawn end
function uv_asynccb end
function uv_timercb end
Expand Down
1 change: 0 additions & 1 deletion base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ function setup_stdio(stdio::Union{IOBuffer, BufferStream}, child_readable::Bool)
@warn "Process error" exception=(ex, catch_backtrace())
finally
close(parent)
child_readable || shutdown(stdio)
end
end
catch ex
Expand Down
Loading