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

Return socket correctly in socket_reuse_port #22017

Merged
merged 3 commits into from
May 22, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Run reuseport tests only if SO_REUSEPORT is supported.
  • Loading branch information
amitmurthy committed May 22, 2017
commit 87378909b3398f1e47de298799361221fa72a2c9
17 changes: 14 additions & 3 deletions test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ include("testenv.jl")

addprocs_with_testenv(4)

# Test that the client port is reused. SO_REUSEPORT may not be supported on
# all UNIX platforms, Linux kernels prior to 3.9 and older versions of OSX
if is_unix()
function reuseport_tests()
# Run the test on all processes.
results = asyncmap(procs()) do p
remotecall_fetch(p) do
Expand Down Expand Up @@ -47,6 +45,19 @@ if is_unix()
@test all(p -> p in results, procs())
end

# Test that the client port is reused. SO_REUSEPORT may not be supported on
# all UNIX platforms, Linux kernels prior to 3.9 and older versions of OSX
if is_unix()
# Run reuse client port tests only if SO_REUSEPORT is supported.
s = TCPSocket(delay = false)
is_linux() && Base.Distributed.bind_client_port(s)
if ccall(:jl_tcp_reuseport, Int32, (Ptr{Void},), s.handle) == 0
reuseport_tests()
else
info("SO_REUSEPORT is unsupported, skipping reuseport tests.")
end
end

id_me = myid()
id_other = filter(x -> x != id_me, procs())[rand(1:(nprocs()-1))]

Expand Down