diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-05-12 12:36:31 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2018-05-12 12:36:31 +1200 |
commit | 33eba29d1e6801af1b2e067503a2f505be3f489b (patch) | |
tree | f35abcdd8baa08633e49078103192074c099c4ce /mitmproxy/net | |
parent | 88fe26997c9da8200722f900992fe1e6f021b34a (diff) | |
download | mitmproxy-33eba29d1e6801af1b2e067503a2f505be3f489b.tar.gz mitmproxy-33eba29d1e6801af1b2e067503a2f505be3f489b.tar.bz2 mitmproxy-33eba29d1e6801af1b2e067503a2f505be3f489b.zip |
tcp: handle EINVAL from closed connections
Fixes #2771
Diffstat (limited to 'mitmproxy/net')
-rw-r--r-- | mitmproxy/net/tcp.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mitmproxy/net/tcp.py b/mitmproxy/net/tcp.py index 18429daa..23284057 100644 --- a/mitmproxy/net/tcp.py +++ b/mitmproxy/net/tcp.py @@ -1,4 +1,5 @@ import os +import errno import select import socket import sys @@ -585,6 +586,13 @@ class TCPServer: with self.handler_counter: try: 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: self.handle_error(connection, client_address) finally: |