From 13436b224ec7f2e8001f960f1d2e05b2275843db Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 4 Jul 2014 21:57:11 +0300 Subject: [PATCH] add EWOULDBLOCK to fix Windows; close #138 --- shadowsocks/tcprelay.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 225fb28..fa10c67 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -166,7 +166,8 @@ class TCPRelayHandler(object): uncomplete = True except (OSError, IOError) as e: error_no = eventloop.errno_from_exception(e) - if error_no in (errno.EAGAIN, errno.EINPROGRESS): + if error_no in (errno.EAGAIN, errno.EINPROGRESS, + errno.EWOULDBLOCK): uncomplete = True else: logging.error(e) @@ -349,7 +350,7 @@ class TCPRelayHandler(object): data = self._local_sock.recv(BUF_SIZE) except (OSError, IOError) as e: if eventloop.errno_from_exception(e) in \ - (errno.ETIMEDOUT, errno.EAGAIN): + (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK): return if not data: self.destroy() @@ -381,7 +382,7 @@ class TCPRelayHandler(object): data = self._remote_sock.recv(BUF_SIZE) except (OSError, IOError) as e: if eventloop.errno_from_exception(e) in \ - (errno.ETIMEDOUT, errno.EAGAIN): + (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK): return if not data: self.destroy() @@ -610,7 +611,8 @@ class TCPRelay(object): self._is_local) except (OSError, IOError) as e: error_no = eventloop.errno_from_exception(e) - if error_no in (errno.EAGAIN, errno.EINPROGRESS): + if error_no in (errno.EAGAIN, errno.EINPROGRESS, + errno.EWOULDBLOCK): continue else: logging.error(e)