|
56 | 56 | # before cleanup of cancelled handles is performed. |
57 | 57 | _MIN_CANCELLED_TIMER_HANDLES_FRACTION = 0.5 |
58 | 58 |
|
59 | | -# Exceptions which must not call the exception handler in fatal error |
60 | | -# methods (_fatal_error()) |
61 | | -_FATAL_ERROR_IGNORE = (BrokenPipeError, |
62 | | - ConnectionResetError, ConnectionAbortedError) |
63 | | - |
64 | 59 | _HAS_IPv6 = hasattr(socket, 'AF_INET6') |
65 | 60 |
|
66 | 61 | # Maximum timeout passed to select to avoid OS limitations |
@@ -96,7 +91,7 @@ def _set_reuseport(sock): |
96 | 91 | 'SO_REUSEPORT defined but not implemented.') |
97 | 92 |
|
98 | 93 |
|
99 | | -def _ipaddr_info(host, port, family, type, proto): |
| 94 | +def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0): |
100 | 95 | # Try to skip getaddrinfo if "host" is already an IP. Users might have |
101 | 96 | # handled name resolution in their own code and pass in resolved IPs. |
102 | 97 | if not hasattr(socket, 'inet_pton'): |
@@ -145,7 +140,7 @@ def _ipaddr_info(host, port, family, type, proto): |
145 | 140 | socket.inet_pton(af, host) |
146 | 141 | # The host has already been resolved. |
147 | 142 | if _HAS_IPv6 and af == socket.AF_INET6: |
148 | | - return af, type, proto, '', (host, port, 0, 0) |
| 143 | + return af, type, proto, '', (host, port, flowinfo, scopeid) |
149 | 144 | else: |
150 | 145 | return af, type, proto, '', (host, port) |
151 | 146 | except OSError: |
@@ -832,7 +827,7 @@ async def _sock_sendfile_fallback(self, sock, file, offset, count): |
832 | 827 | read = await self.run_in_executor(None, file.readinto, view) |
833 | 828 | if not read: |
834 | 829 | break # EOF |
835 | | - await self.sock_sendall(sock, view) |
| 830 | + await self.sock_sendall(sock, view[:read]) |
836 | 831 | total_sent += read |
837 | 832 | return total_sent |
838 | 833 | finally: |
@@ -1083,11 +1078,11 @@ async def _sendfile_fallback(self, transp, file, offset, count): |
1083 | 1078 | if blocksize <= 0: |
1084 | 1079 | return total_sent |
1085 | 1080 | view = memoryview(buf)[:blocksize] |
1086 | | - read = file.readinto(view) |
| 1081 | + read = await self.run_in_executor(None, file.readinto, view) |
1087 | 1082 | if not read: |
1088 | 1083 | return total_sent # EOF |
1089 | 1084 | await proto.drain() |
1090 | | - transp.write(view) |
| 1085 | + transp.write(view[:read]) |
1091 | 1086 | total_sent += read |
1092 | 1087 | finally: |
1093 | 1088 | if total_sent > 0 and hasattr(file, 'seek'): |
@@ -1229,7 +1224,8 @@ async def create_datagram_endpoint(self, protocol_factory, |
1229 | 1224 | if local_addr: |
1230 | 1225 | sock.bind(local_address) |
1231 | 1226 | if remote_addr: |
1232 | | - await self.sock_connect(sock, remote_address) |
| 1227 | + if not allow_broadcast: |
| 1228 | + await self.sock_connect(sock, remote_address) |
1233 | 1229 | r_addr = remote_address |
1234 | 1230 | except OSError as exc: |
1235 | 1231 | if sock is not None: |
@@ -1270,7 +1266,7 @@ async def _ensure_resolved(self, address, *, |
1270 | 1266 | family=0, type=socket.SOCK_STREAM, |
1271 | 1267 | proto=0, flags=0, loop): |
1272 | 1268 | host, port = address[:2] |
1273 | | - info = _ipaddr_info(host, port, family, type, proto) |
| 1269 | + info = _ipaddr_info(host, port, family, type, proto, *address[2:]) |
1274 | 1270 | if info is not None: |
1275 | 1271 | # "host" is already a resolved IP. |
1276 | 1272 | return [info] |
|
0 commit comments