mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-15 22:09:31 -04:00
Gracefully handle TCP client disconnections
Prevent premature client disconnections during reading from triggering
unhandled exceptions in TCP connection handling code.
(cherry picked from commit e4c3186a7c)
This commit is contained in:
parent
5316ccf083
commit
cb9420b8cf
1 changed files with 4 additions and 0 deletions
|
|
@ -542,10 +542,14 @@ class AsyncDnsServer(AsyncServer):
|
|||
peer = Peer(peer_info[0], peer_info[1])
|
||||
|
||||
wire_length_bytes = await reader.read(2)
|
||||
if len(wire_length_bytes) < 2:
|
||||
return
|
||||
(wire_length,) = struct.unpack("!H", wire_length_bytes)
|
||||
logging.debug("Receiving TCP message (%d octets)...", wire_length)
|
||||
|
||||
wire = await reader.read(wire_length)
|
||||
if len(wire) < wire_length:
|
||||
return
|
||||
full_message = wire_length_bytes + wire
|
||||
logging.debug("Received complete TCP message: %s", full_message.hex())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue