From f03f6ad7696473c488b8f55e30c76855a304df0b Mon Sep 17 00:00:00 2001 From: Egor Churaev Date: Fri, 4 Dec 2020 00:12:48 +0300 Subject: [PATCH] [RPC] Prefer IPv4 between IPv4 and IPv6 (#7013) This change fix problem with version of IP protocol on MacOS. Previous the `rpc_tracker` and `query_rpc_tracker` were not able connect to each other with default hostnames. The root cause was in method `socket.getaddrinfo`. In `rpc_tracker` the default hostname is "0.0.0.0" and `getaddrinfo` returns IPv4 type. In `query_rpc_tracker` the default hastname is "localhost" and `getaddrinfo` on MacOS returns IPv6 type. Note: on Linux both have IPv4 type. These tools worked by different protocols and this is why `query_rpc_tracker` wasn't able connect to `rpc_tracker`. Now we will prefer IPv4 type. And both `rpc_tracker` and `query_rpc_tracker` will use the same version of protocol. --- python/tvm/rpc/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/tvm/rpc/base.py b/python/tvm/rpc/base.py index b2bfa3b53416..1be904524ef6 100644 --- a/python/tvm/rpc/base.py +++ b/python/tvm/rpc/base.py @@ -60,6 +60,9 @@ class TrackerCode(object): def get_addr_family(addr): res = socket.getaddrinfo(addr[0], addr[1], 0, 0, socket.IPPROTO_TCP) + for info in res: + if info[0] == socket.AF_INET: + return info[0] return res[0][0]