tcp: handle EINVAL from closed connections

Fixes #2771
This commit is contained in:
Aldo Cortesi 2018-05-12 12:36:31 +12:00
parent 88fe26997c
commit 33eba29d1e

View File

@ -1,4 +1,5 @@
import os import os
import errno
import select import select
import socket import socket
import sys import sys
@ -585,6 +586,13 @@ class TCPServer:
with self.handler_counter: with self.handler_counter:
try: try:
self.handle_client_connection(connection, client_address) self.handle_client_connection(connection, client_address)
except OSError as e:
# This catches situations where the underlying connection is
# closed beneath us. Syscalls on the connection object at this
# point returns EINVAL. If this happens, we close the socket and
# move on.
if not e.errno == errno.EINVAL:
raise
except: except:
self.handle_error(connection, client_address) self.handle_error(connection, client_address)
finally: finally: