From e63980fb6b41ac5f8fda278331229fbcffd7f46d Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Fri, 19 Oct 2018 20:07:42 -0400 Subject: [PATCH] iostream: Add errno 0 to the list of silent errors in TLS handshakes This error is possible for some connections that don't follow through with the TLS handshake. Fixes #2504 --- tornado/iostream.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tornado/iostream.py b/tornado/iostream.py index 6d5cae972..2fd2814d5 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -1402,7 +1402,13 @@ class SSLIOStream(IOStream): # to cause do_handshake to raise EBADF and ENOTCONN, so make # those errors quiet as well. # https://groups.google.com/forum/?fromgroups#!topic/python-tornado/ApucKJat1_0 - if self._is_connreset(err) or err.args[0] in (errno.EBADF, errno.ENOTCONN): + # Errno 0 is also possible in some cases (nc -z). + # https://github.com/tornadoweb/tornado/issues/2504 + if self._is_connreset(err) or err.args[0] in ( + 0, + errno.EBADF, + errno.ENOTCONN, + ): return self.close(exc_info=err) raise except AttributeError as err: -- 2.47.2