From: Ben Darnell Date: Sun, 18 Jan 2015 21:20:55 +0000 (-0500) Subject: Work around an occasional EPROTOTYPE error on OSX. X-Git-Tag: v4.1.0b1~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6740e3101ce759590d4d7ca3ebe99e5d707abb5;p=thirdparty%2Ftornado.git Work around an occasional EPROTOTYPE error on OSX. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index d14ec0fdb..640198d87 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -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,)