|
@@ -741,12 +741,14 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
|
|
# to care about the SOCK_STREAM parameter at all (which it really is,
|
|
# to care about the SOCK_STREAM parameter at all (which it really is,
|
|
# except for testing)
|
|
# except for testing)
|
|
if socket.has_ipv6:
|
|
if socket.has_ipv6:
|
|
- sock = socket.fromfd(sock_fd, socket.AF_INET6, socket.SOCK_STREAM)
|
|
|
|
|
|
+ socktype = socket.AF_INET6
|
|
else:
|
|
else:
|
|
# To make it work even on hosts without IPv6 support
|
|
# To make it work even on hosts without IPv6 support
|
|
# (Any idea how to simulate this in test?)
|
|
# (Any idea how to simulate this in test?)
|
|
- sock = socket.fromfd(sock_fd, socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
- peer = sock.getpeername()
|
|
|
|
|
|
+ socktype = socket.AF_INET
|
|
|
|
+
|
|
|
|
+ with socket.fromfd(sock_fd, socktype, socket.SOCK_STREAM) as sock:
|
|
|
|
+ peer = sock.getpeername()
|
|
|
|
|
|
# Identify the correct socket family. Due to the above "trick",
|
|
# Identify the correct socket family. Due to the above "trick",
|
|
# we cannot simply use sock.family.
|
|
# we cannot simply use sock.family.
|
|
@@ -756,8 +758,6 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
|
|
except socket.error:
|
|
except socket.error:
|
|
family = socket.AF_INET
|
|
family = socket.AF_INET
|
|
|
|
|
|
- sock.close()
|
|
|
|
-
|
|
|
|
return (family, socket.SOCK_STREAM, peer)
|
|
return (family, socket.SOCK_STREAM, peer)
|
|
|
|
|
|
def finish_request(self, sock_fd, request_data):
|
|
def finish_request(self, sock_fd, request_data):
|