mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
python: Reconnect SSL connections when ovsdb-server restarts.
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 <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Numan Siddique <nusiddiq@redhat.com>
This commit is contained in:
@@ -451,6 +451,8 @@ class SSLStream(Stream):
|
||||
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
|
||||
|
||||
@@ -459,6 +461,10 @@ class SSLStream(Stream):
|
||||
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:
|
||||
|
Reference in New Issue
Block a user