mirror of https://github.com/python/cpython
Issue #8184: Fix a potential file descriptor leak when a
multiprocessing.Connection socket can't be bound.
This commit is contained in:
parent
4c79aec716
commit
709aa35a7a
|
@ -249,10 +249,14 @@ class SocketListener(object):
|
||||||
'''
|
'''
|
||||||
def __init__(self, address, family, backlog=1):
|
def __init__(self, address, family, backlog=1):
|
||||||
self._socket = socket.socket(getattr(socket, family))
|
self._socket = socket.socket(getattr(socket, family))
|
||||||
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
try:
|
||||||
self._socket.bind(address)
|
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
self._socket.listen(backlog)
|
self._socket.bind(address)
|
||||||
self._address = self._socket.getsockname()
|
self._socket.listen(backlog)
|
||||||
|
self._address = self._socket.getsockname()
|
||||||
|
except socket.error:
|
||||||
|
self._socket.close()
|
||||||
|
raise
|
||||||
self._family = family
|
self._family = family
|
||||||
self._last_accepted = None
|
self._last_accepted = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue