Skip to content

Commit f44d380

Browse files
test ...
1 parent 7c8c598 commit f44d380

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/cluster.jl

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ mutable struct LocalProcess
208208
id0::Int
209209
id1::Int
210210
bind_addr::String
211+
bind_addr_2::String
211212
bind_port::UInt16
212213
cookie::String
213214
LocalProcess() = new(1,1)
@@ -273,7 +274,7 @@ function start_worker(out::IO, cookie::AbstractString=readline(stdin); close_std
273274
client = accept(sock)
274275
process_messages(client, client, true; role = :worker)
275276
end)
276-
println(out, "julia_worker:$(string(LPROC.bind_port))#$(LPROC.bind_addr)\n") # print header
277+
println(out, "julia_worker:$(string(LPROC.bind_port))#$(LPROC.bind_addr_2)\n") # print header
277278
flush(out)
278279

279280
Sockets.nagle(sock, false)
@@ -1384,7 +1385,7 @@ function terminate_all_workers(;role= :default)
13841385
end
13851386

13861387
# initialize the local proc network address / port
1387-
function init_bind_addr()
1388+
#=function init_bind_addr()
13881389
opts = JLOptions()
13891390
if opts.bindto != C_NULL
13901391
bind_to = split(unsafe_string(opts.bindto), ":")
@@ -1413,6 +1414,43 @@ function init_bind_addr()
14131414
LPROC.bind_addr = bind_addr
14141415
LPROC.bind_port = UInt16(bind_port)
14151416
end
1417+
=#
1418+
1419+
function init_bind_addr()
1420+
opts = JLOptions()
1421+
1422+
@info "A2: $(getipaddrs(IPv4; loopback = false))"
1423+
bind_port = 0
1424+
try
1425+
ips = getipaddrs(IPv4; loopback = false)
1426+
n = length(ips)
1427+
bind_addr = string(ips[n])
1428+
#@info "ADDR: $(getipaddrs())"
1429+
catch
1430+
# All networking is unavailable, initialize bind_addr to the loopback address
1431+
# Will cause an exception to be raised only when used.
1432+
bind_addr = "127.0.0.1"
1433+
end
1434+
1435+
if opts.bindto != C_NULL
1436+
bind_to = split(unsafe_string(opts.bindto), ":")
1437+
@info "A1: $bind_to"
1438+
bind_addr_2 = string(parse(IPAddr, bind_to[1]))
1439+
if length(bind_to) > 1
1440+
bind_port = parse(Int,bind_to[2])
1441+
else
1442+
bind_port = 0
1443+
end
1444+
else
1445+
bind_addr_2 = bind_addr
1446+
end
1447+
1448+
global LPROC
1449+
LPROC.bind_addr = bind_addr
1450+
LPROC.bind_addr_2 = bind_addr_2
1451+
LPROC.bind_port = UInt16(bind_port)
1452+
end
1453+
14161454

14171455
using Random: randstring
14181456

0 commit comments

Comments
 (0)