Skip to content

Commit 33f7ad9

Browse files
author
clowwindy
committed
fix EINPROGESS
1 parent c3e5c6f commit 33f7ad9

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

shadowsocks/local.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
print >>sys.stderr, 'warning: gevent not found, using threading instead'
3838

3939
import socket
40+
import eventloop
41+
import errno
4042
import select
4143
import SocketServer
4244
import struct
@@ -105,7 +107,13 @@ def handle_tcp(sock, remote, encryptor, pending_data=None,
105107
data = encryptor.encrypt(pending_data + data)
106108
pending_data = None
107109
logging.info('fast open %s:%d' % (server, port))
108-
remote.sendto(data, MSG_FASTOPEN, (server, port))
110+
try:
111+
remote.sendto(data, MSG_FASTOPEN, (server, port))
112+
except (OSError, IOError) as e:
113+
if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
114+
pass
115+
else:
116+
raise e
109117
connected = True
110118
fdset = [sock, remote]
111119
else:
@@ -232,17 +240,12 @@ def handle(self):
232240
socket.TCP_NODELAY, 1)
233241
Socks5Server.handle_tcp(sock, remote, encryptor,
234242
addr_to_send)
235-
finally:
236-
pass
237-
# except socket.error, e:
238-
# raise e
239-
# logging.warn(e)
240-
# return
241-
finally:
242-
pass
243-
# except socket.error, e:
244-
# raise e
245-
# logging.warn(e)
243+
except (OSError, IOError) as e:
244+
logging.warn(e)
245+
return
246+
except (OSError, IOError) as e:
247+
raise e
248+
logging.warn(e)
246249

247250

248251
def main():

0 commit comments

Comments
 (0)