]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Work around an occasional EPROTOTYPE error on OSX.
authorBen Darnell <ben@bendarnell.com>
Sun, 18 Jan 2015 21:20:55 +0000 (16:20 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 18 Jan 2015 21:20:55 +0000 (16:20 -0500)
tornado/iostream.py

index d14ec0fdbca9886a31d3a67ce104cd43ab955e1a..640198d87c9d7e13dfd73d8ba0b10a80d86d5fc7 100644 (file)
@@ -68,6 +68,14 @@ _ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE,
 if hasattr(errno, "WSAECONNRESET"):
     _ERRNO_CONNRESET += (errno.WSAECONNRESET, errno.WSAECONNABORTED, errno.WSAETIMEDOUT)
 
+if sys.platform == 'darwin':
+    # OSX appears to have a race condition that causes send(2) to return
+    # EPROTOTYPE if called while a socket is being torn down:
+    # http://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
+    # Since the socket is being closed anyway, treat this as an ECONNRESET
+    # instead of an unexpected error.
+    _ERRNO_CONNRESET += (errno.EPROTOTYPE,)
+
 # More non-portable errnos:
 _ERRNO_INPROGRESS = (errno.EINPROGRESS,)