diff mbox

[ovs-dev] python: Fix The SSL connection is not reconnected when the OVSDB Server is restarted

Message ID 20161204102817.18056-1-ligs@dtdream.com
State Superseded
Headers show

Commit Message

Guoshuai Li Dec. 4, 2016, 10:28 a.m. UTC
When the SSL connection is disconnected by the peer
the client's do_handshake() function throws the exception OpenSSL.SSL.SysCallError
we need to catch the exception and return the exception errno so that the SSL connection can be reconnected.
And the recv() function throws the exception OpenSSL.SSL.ZeroReturnError
This exception refers to TCP connection normal closed, return (0, "")
---
 python/ovs/stream.py | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index b43e105..68dffbc 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -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,8 @@  class SSLStream(Stream):
             return super(SSLStream, self).recv(n)
         except SSL.WantReadError:
             return (errno.EAGAIN, "")
+        except SSL.ZeroReturnError as e:
+            return (0, "")
 
     def send(self, buf):
         try: