mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
#15277: Fix a resource leak in support.py when IPv6 is disabled.
The leak occurred by setting: echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 before running test_support. Patch by Brian Brazil.
This commit is contained in:
parent
9a9c28ce7a
commit
121d59ffa9
2 changed files with 11 additions and 3 deletions
|
|
@ -493,14 +493,16 @@ def bind_port(sock, host=HOST):
|
||||||
def _is_ipv6_enabled():
|
def _is_ipv6_enabled():
|
||||||
"""Check whether IPv6 is enabled on this host."""
|
"""Check whether IPv6 is enabled on this host."""
|
||||||
if socket.has_ipv6:
|
if socket.has_ipv6:
|
||||||
|
sock = None
|
||||||
try:
|
try:
|
||||||
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||||
sock.bind(('::1', 0))
|
sock.bind(('::1', 0))
|
||||||
|
return True
|
||||||
except (socket.error, socket.gaierror):
|
except (socket.error, socket.gaierror):
|
||||||
pass
|
pass
|
||||||
else:
|
finally:
|
||||||
|
if sock:
|
||||||
sock.close()
|
sock.close()
|
||||||
return True
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
IPV6_ENABLED = _is_ipv6_enabled()
|
IPV6_ENABLED = _is_ipv6_enabled()
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,12 @@ Tools/Demos
|
||||||
* C frames that are garbage-collecting
|
* C frames that are garbage-collecting
|
||||||
* C frames that are due to the invocation of a PyCFunction
|
* C frames that are due to the invocation of a PyCFunction
|
||||||
|
|
||||||
|
Tests
|
||||||
|
-----
|
||||||
|
|
||||||
|
- Issue #15277: Fix a resource leak in support.py when IPv6 is disabled.
|
||||||
|
Patch by Brian Brazil.
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue