File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -1279,12 +1279,25 @@ function terminate_all_workers()
12791279end
12801280
12811281function choose_bind_addr ()
1282- # On HPC clusters, link-local addresses are usually not usable for
1283- # communication between compute nodes.
1284- # Therefore, we use the first non-link-local IPv4 address.
1285- addrs = Sockets. getipaddrs (Sockets. IPv4)
1286- filter! (! Sockets. islinklocaladdr, addrs)
1287- return first (addrs)
1282+ # We prefer IPv4 over IPv6.
1283+ #
1284+ # We also prefer non-link-local over link-local.
1285+ # (This is because on HPC clusters, link-local addresses are usually not
1286+ # usable for communication between compute nodes.
1287+ #
1288+ # Therefore, our order of preference is:
1289+ # 1. Non-link-local IPv4
1290+ # 2. Non-link-local IPv6
1291+ # 3. Link-local IPv4
1292+ # 4. Link-local IPv6
1293+ addrs = getipaddrs ()
1294+ i = something (
1295+ findfirst (ip -> ! islinklocaladdr (ip) && ip isa IPv4, addrs), # first non-link-local IPv4
1296+ findfirst (ip -> ! islinklocaladdr (ip), addrs), # first non-link-local
1297+ findfirst (ip -> ip isa IPv4, addrs), # first IPv4
1298+ 1 , # first address
1299+ )
1300+ return addrs[i]
12881301end
12891302
12901303# initialize the local proc network address / port
You can’t perform that action at this time.
0 commit comments