From cb4fc44a401014ad4d4f64dc2e7049ca51ab2fd9 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Mon, 22 Oct 2018 15:28:42 -0400 Subject: [PATCH] Use `require(pkgid, ...)` instead of relative require Co-authored-by: Jameson Nash --- base/client.jl | 6 +++++- base/stream.jl | 8 ++------ stdlib/Sockets/test/runtests.jl | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/base/client.jl b/base/client.jl index 746c2e30ad474..f10162897fd5a 100644 --- a/base/client.jl +++ b/base/client.jl @@ -226,7 +226,11 @@ function exec_options(opts) # Load Distributed module only if any of the Distributed options have been specified. distributed_mode = (opts.worker == 1) || (opts.nprocs > 0) || (opts.machine_file != C_NULL) if distributed_mode - Core.eval(Main, :(using Distributed)) + let Distributed = require(PkgId(UUID((0x8ba89e20_285c_5b6f, 0x9357_94700520ee1b)), "Distributed")) + Core.eval(Main, :(const Distributed = $Distributed)) + Core.eval(Main, :(using .Distributed)) + end + invokelatest(Main.Distributed.process_opts, opts) end diff --git a/base/stream.jl b/base/stream.jl index a121131ce93ad..3d54865c89732 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -216,8 +216,6 @@ unlock(s::LibuvStream) = unlock(s.lock) rawhandle(stream::LibuvStream) = stream.handle unsafe_convert(::Type{Ptr{Cvoid}}, s::Union{LibuvStream, LibuvServer}) = s.handle -const Sockets_mod = Ref{Module}() - function init_stdio(handle::Ptr{Cvoid}) t = ccall(:jl_uv_handle_type, Int32, (Ptr{Cvoid},), handle) if t == UV_FILE @@ -233,10 +231,8 @@ function init_stdio(handle::Ptr{Cvoid}) elseif t == UV_TTY return TTY(handle, StatusOpen) elseif t == UV_TCP - if !isassigned(Sockets_mod) - Sockets_mod[] = Base.require(Base, :Sockets) - end - return Sockets_mod[].TCPSocket(handle, StatusOpen) + Sockets = require(PkgId(UUID((0x6462fe0b_24de_5631, 0x8697_dd941f90decc)), "Sockets")) + return Sockets.TCPSocket(handle, StatusOpen) elseif t == UV_NAMED_PIPE return PipeEndpoint(handle, StatusOpen) else diff --git a/stdlib/Sockets/test/runtests.jl b/stdlib/Sockets/test/runtests.jl index 0d54b75ffacb5..6145f87616f0d 100644 --- a/stdlib/Sockets/test/runtests.jl +++ b/stdlib/Sockets/test/runtests.jl @@ -433,6 +433,21 @@ end end end +@static if !Sys.iswindows() + # Issue #29234 + @testset "TCPSocket stdin" begin + let addr = Sockets.InetAddr(ip"127.0.0.1", 4455) + srv = listen(addr) + s = connect(addr) + + @test success(pipeline(`$(Base.julia_cmd()) -e "exit()" -i`, stdin=s)) + + close(s) + close(srv) + end + end +end + # Issues #18818 and #24169 mutable struct RLimit cur::Int64