Skip to content

Commit

Permalink
python: Reconnect SSL connections when ovsdb-server restarts.
Browse files Browse the repository at this point in the history
The do_handshake() function throws the exception OpenSSL.SSL.SysCallError
when the peer's SSL connection is closed, And the recv() function also
throws the exception OpenSSL.SSL.SysCallError when the peer's SSL
connection is abnormally closed, This commit catches the exception and
return error's errno.

Similarly, the recv() function also throws the exception
OpenSSL.SSL.ZeroReturnError when the peer's SSL connection is closed.  This
exception refers to TCP connection normal closed, return (0, "")

Signed-off-by: Guoshuai Li <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Numan Siddique <[email protected]>
  • Loading branch information
Guoshuai Li authored and blp committed Dec 12, 2016
1 parent 905d453 commit 2dc7e5e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/ovs/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ def connect(self):
self.socket.do_handshake()
except SSL.WantReadError:
return errno.EAGAIN
except SSL.SysCallError as e:
return ovs.socket_util.get_exception_errno(e)

return 0

Expand All @@ -459,6 +461,10 @@ def recv(self, n):
return super(SSLStream, self).recv(n)
except SSL.WantReadError:
return (errno.EAGAIN, "")
except SSL.SysCallError as e:
return (ovs.socket_util.get_exception_errno(e), "")
except SSL.ZeroReturnError:
return (0, "")

def send(self, buf):
try:
Expand Down

0 comments on commit 2dc7e5e

Please sign in to comment.