Skip to content

Commit

Permalink
add EWOULDBLOCK to fix Windows; close #138
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jul 4, 2014
1 parent d82441e commit 13436b2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shadowsocks/tcprelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def _write_to_sock(self, data, sock):
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)
Expand Down Expand Up @@ -349,7 +350,7 @@ def _on_local_read(self):
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()
Expand Down Expand Up @@ -381,7 +382,7 @@ def _on_remote_read(self):
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()
Expand Down Expand Up @@ -610,7 +611,8 @@ def _handle_events(self, events):
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)
Expand Down

0 comments on commit 13436b2

Please sign in to comment.