mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +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 748ed4259b
)
This commit is contained in:
@@ -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(
|
||||
|
Reference in New Issue
Block a user