From: Ben Darnell Date: Sat, 20 Oct 2018 00:07:42 +0000 (-0400) Subject: iostream: Add errno 0 to the list of silent errors in TLS handshakes X-Git-Tag: v6.0.0b1~26^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e63980fb6b41ac5f8fda278331229fbcffd7f46d;p=thirdparty%2Ftornado.git 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 --- 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: