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])
|
peer = Peer(peer_info[0], peer_info[1])
|
||||||
|
|
||||||
for _ in range(0, 1):
|
for _ in range(0, 1):
|
||||||
wire = await self._read_tcp_query(reader)
|
try:
|
||||||
if not wire:
|
wire = await self._read_tcp_query(reader)
|
||||||
break
|
if not wire:
|
||||||
await self._send_tcp_response(writer, peer, 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()
|
writer.close()
|
||||||
await writer.wait_closed()
|
await writer.wait_closed()
|
||||||
@@ -587,11 +591,7 @@ class AsyncDnsServer(AsyncServer):
|
|||||||
responses = self._handle_query(wire, peer, DnsProtocol.TCP)
|
responses = self._handle_query(wire, peer, DnsProtocol.TCP)
|
||||||
async for response in responses:
|
async for response in responses:
|
||||||
writer.write(response)
|
writer.write(response)
|
||||||
try:
|
await writer.drain()
|
||||||
await writer.drain()
|
|
||||||
except ConnectionResetError:
|
|
||||||
logging.error("TCP connection from %s reset by peer", peer)
|
|
||||||
return
|
|
||||||
|
|
||||||
def _log_query(self, qctx: QueryContext, peer: Peer, protocol: DnsProtocol) -> None:
|
def _log_query(self, qctx: QueryContext, peer: Peer, protocol: DnsProtocol) -> None:
|
||||||
logging.info(
|
logging.info(
|
||||||
|
Reference in New Issue
Block a user