Mercurial > hg
comparison tests/run-tests.py @ 30985:1f803482844a
runtests: checkportisavailable should only check one family
As explained by the previous patch, checkportisavailable() should only check
the preferred family - either IPv4 or IPv6, not both.
This patch makes it so.
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 15 Feb 2017 16:22:22 -0800 |
parents | 15f9084a9a0c |
children | f07ca071a058 |
comparison
equal
deleted
inserted
replaced
30984:15f9084a9a0c | 30985:1f803482844a |
---|---|
135 | 135 |
136 useipv6 = checkipv6available() | 136 useipv6 = checkipv6available() |
137 | 137 |
138 def checkportisavailable(port): | 138 def checkportisavailable(port): |
139 """return true if a port seems free to bind on localhost""" | 139 """return true if a port seems free to bind on localhost""" |
140 families = [getattr(socket, i, None) | 140 if useipv6: |
141 for i in ('AF_INET', 'AF_INET6') | 141 family = socket.AF_INET6 |
142 if getattr(socket, i, None) is not None] | 142 else: |
143 for family in families: | 143 family = socket.AF_INET |
144 if True: | |
144 try: | 145 try: |
145 s = socket.socket(family, socket.SOCK_STREAM) | 146 s = socket.socket(family, socket.SOCK_STREAM) |
146 s.bind(('localhost', port)) | 147 s.bind(('localhost', port)) |
147 s.close() | 148 s.close() |
148 return True | 149 return True |