Message ID | 20161207063822.16124-1-ligs@dtdream.com |
---|---|
State | Accepted |
Headers | show |
On Wed, Dec 7, 2016 at 12:08 PM, Guoshuai Li <ligs@dtdream.com> wrote: > 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 <ligs@dtdream.com> > > Acked-by: Numan Siddique <nusiddiq@redhat.com>
On Wed, Dec 07, 2016 at 07:36:14PM +0530, Numan Siddique wrote: > On Wed, Dec 7, 2016 at 12:08 PM, Guoshuai Li <ligs@dtdream.com> wrote: > > > 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 <ligs@dtdream.com> > > > > > Acked-by: Numan Siddique <nusiddiq@redhat.com> Thanks, applied to master.
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:
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 <ligs@dtdream.com> --- python/ovs/stream.py | 6 ++++++ 1 file changed, 6 insertions(+)