mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-34139: Remove unix datagram socket from FS before binding (GH-8323)
https://bugs.python.org/issue34139
This commit is contained in:
parent
5aaac94eeb
commit
56065d4c8a
3 changed files with 29 additions and 0 deletions
|
@ -20,6 +20,7 @@ import heapq
|
|||
import itertools
|
||||
import os
|
||||
import socket
|
||||
import stat
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
|
@ -1183,6 +1184,19 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
for addr in (local_addr, remote_addr):
|
||||
if addr is not None and not isinstance(addr, str):
|
||||
raise TypeError('string is expected')
|
||||
|
||||
if local_addr and local_addr[0] not in (0, '\x00'):
|
||||
try:
|
||||
if stat.S_ISSOCK(os.stat(local_addr).st_mode):
|
||||
os.remove(local_addr)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except OSError as err:
|
||||
# Directory may have permissions only to create socket.
|
||||
logger.error('Unable to check or remove stale UNIX '
|
||||
'socket %r: %r',
|
||||
local_addr, err)
|
||||
|
||||
addr_pairs_info = (((family, proto),
|
||||
(local_addr, remote_addr)), )
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue