]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
iostream: Add errno 0 to the list of silent errors in TLS handshakes 2518/head
authorBen Darnell <ben@bendarnell.com>
Sat, 20 Oct 2018 00:07:42 +0000 (20:07 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 20 Oct 2018 00:58:44 +0000 (20:58 -0400)
This error is possible for some connections that don't follow through
with the TLS handshake.

Fixes #2504

tornado/iostream.py

index 6d5cae972931e657a8a758f01825c5dbdf0dd723..2fd2814d5970f719aad6ef8bbf117f1ea2896c3b 100644 (file)
@@ -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: