From patchwork Wed Dec 7 06:38:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoshuai Li X-Patchwork-Id: 703457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tYTNS5KXzz9svs for ; Wed, 7 Dec 2016 17:38:48 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6A2AB8F5; Wed, 7 Dec 2016 06:38:45 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5A78089C for ; Wed, 7 Dec 2016 06:38:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp2203-239.mail.aliyun.com (smtp2203-239.mail.aliyun.com [121.197.203.239]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id D3C5D141 for ; Wed, 7 Dec 2016 06:38:39 +0000 (UTC) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.3136664|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03307; MF=ligs@dtdream.com; NM=1; PH=DS; RN=2; RT=2; SR=0; TI=SMTPD_---.7Gj6cpS_1481092714; Received: from localhost.localdomain(mailfrom:ligs@dtdream.com ip:111.198.29.132) by smtp.aliyun-inc.com(10.147.40.26); Wed, 07 Dec 2016 14:38:35 +0800 From: Guoshuai Li To: ovs-dev@openvswitch.org Date: Wed, 7 Dec 2016 14:38:22 +0800 Message-Id: <20161207063822.16124-1-ligs@dtdream.com> X-Mailer: git-send-email 2.10.1.windows.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Guoshuai Li Subject: [ovs-dev] [PATCH V3] python: Fix The SSL connection is not reconnected when the OVSDB Server is restarted X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- 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: