Skip to content

Commit

Permalink
Improove error handling during TLS handshake
Browse files Browse the repository at this point in the history
if client already disconnected immediately.

Traceback (most recent call last):
  File "/home/spaceone/git/circuits/circuits/core/manager.py", line 834, in processTask
    value = next(task)
  File "/home/spaceone/git/circuits/circuits/net/sockets.py", line 614, in _accept
    self._on_accept_done(newsock)
  File "/home/spaceone/git/circuits/circuits/net/sockets.py", line 636, in _on_accept_done
    self.fire(connect(sock, *sock.getpeername()))
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 107] Transport endpoint is not connected
  • Loading branch information
spaceone committed Jan 24, 2019
1 parent 7fea2d0 commit f6ffc70
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion circuits/net/sockets.py
Expand Up @@ -633,7 +633,14 @@ def _on_accept_done(self, sock, fire_connect_event=True):
self._poller.addReader(self, sock)
self._clients.append(sock)
if fire_connect_event:
self.fire(connect(sock, *sock.getpeername()))
try:
self.fire(connect(sock, *sock.getpeername()))
except SocketError as exc:
if exc.args[0] in (ENOTCONN,):
# the client already disconnected
self._close(sock)
return
raise

def _on_handshake_error(self, sock, err):
self.fire(error(sock, err))
Expand Down

0 comments on commit f6ffc70

Please sign in to comment.