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, we need to catch the exception and return error's errno.
And the recv() function also throws the exception OpenSSL.SSL.ZeroReturnError when the peer's SSL connection is normal closed. This exception refers to TCP connection normal closed, return (0, "") Signed-off-by: Guoshuai Li <[email protected]> --- python/ovs/stream.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/ovs/stream.py b/python/ovs/stream.py index b43e105..a012e56 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,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: -- 2.10.1.windows.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
