Browse Source

fix EINPROGESS

1.4
clowwindy 11 years ago
parent
commit
33f7ad9e8f
  1. 25
      shadowsocks/local.py

25
shadowsocks/local.py

@ -37,6 +37,8 @@ except ImportError:
print >>sys.stderr, 'warning: gevent not found, using threading instead' print >>sys.stderr, 'warning: gevent not found, using threading instead'
import socket import socket
import eventloop
import errno
import select import select
import SocketServer import SocketServer
import struct import struct
@ -105,7 +107,13 @@ class Socks5Server(SocketServer.StreamRequestHandler):
data = encryptor.encrypt(pending_data + data) data = encryptor.encrypt(pending_data + data)
pending_data = None pending_data = None
logging.info('fast open %s:%d' % (server, port)) logging.info('fast open %s:%d' % (server, port))
try:
remote.sendto(data, MSG_FASTOPEN, (server, port)) remote.sendto(data, MSG_FASTOPEN, (server, port))
except (OSError, IOError) as e:
if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
pass
else:
raise e
connected = True connected = True
fdset = [sock, remote] fdset = [sock, remote]
else: else:
@ -232,17 +240,12 @@ class Socks5Server(SocketServer.StreamRequestHandler):
socket.TCP_NODELAY, 1) socket.TCP_NODELAY, 1)
Socks5Server.handle_tcp(sock, remote, encryptor, Socks5Server.handle_tcp(sock, remote, encryptor,
addr_to_send) addr_to_send)
finally: except (OSError, IOError) as e:
pass logging.warn(e)
# except socket.error, e: return
# raise e except (OSError, IOError) as e:
# logging.warn(e) raise e
# return logging.warn(e)
finally:
pass
# except socket.error, e:
# raise e
# logging.warn(e)
def main(): def main():

Loading…
Cancel
Save