mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Handle connection resets during reading
A TCP peer may reset the connection at any point, but asyncserver.py currently only handles connection resets when it is sending data to the client. Handle connection resets during reading in the same way. (cherry picked from commit 748ed4259b66e4b33acf1d2584dc92da00d31aec)
This commit is contained in:
parent
7178efbf47
commit
3a1c0dba80
@ -542,10 +542,14 @@ class AsyncDnsServer(AsyncServer):
|
||||
peer = Peer(peer_info[0], peer_info[1])
|
||||
|
||||
for _ in range(0, 1):
|
||||
wire = await self._read_tcp_query(reader)
|
||||
if not wire:
|
||||
break
|
||||
await self._send_tcp_response(writer, peer, wire)
|
||||
try:
|
||||
wire = await self._read_tcp_query(reader)
|
||||
if not wire:
|
||||
break
|
||||
await self._send_tcp_response(writer, peer, wire)
|
||||
except ConnectionResetError:
|
||||
logging.error("TCP connection from %s reset by peer", peer)
|
||||
return
|
||||
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
@ -587,11 +591,7 @@ class AsyncDnsServer(AsyncServer):
|
||||
responses = self._handle_query(wire, peer, DnsProtocol.TCP)
|
||||
async for response in responses:
|
||||
writer.write(response)
|
||||
try:
|
||||
await writer.drain()
|
||||
except ConnectionResetError:
|
||||
logging.error("TCP connection from %s reset by peer", peer)
|
||||
return
|
||||
await writer.drain()
|
||||
|
||||
def _log_query(self, qctx: QueryContext, peer: Peer, protocol: DnsProtocol) -> None:
|
||||
logging.info(
|
||||
|
Loading…
x
Reference in New Issue
Block a user