diff mbox

[ovs-dev] python: Catch exception "SSL.SysCallError" for send by SSL.

Message ID 20170107062835.22180-1-ligs@dtdream.com
State Accepted
Headers show

Commit Message

Guoshuai Li Jan. 7, 2017, 6:28 a.m. UTC
When OVSDB server is aborted,
the SSL send function will throw SSL.SysCallError exception,
which we need to catch and return it's -errno.

While SSL.WantWriteError exception needs to return -EAGAIN
based on its parent class, not EAGAIN

Signed-off-by: Guoshuai Li <ligs@dtdream.com>
---
 python/ovs/stream.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ben Pfaff Jan. 14, 2017, 4:51 p.m. UTC | #1
On Sat, Jan 07, 2017 at 02:28:35PM +0800, Guoshuai Li wrote:
> When OVSDB server is aborted,
> the SSL send function will throw SSL.SysCallError exception,
> which we need to catch and return it's -errno.
> 
> While SSL.WantWriteError exception needs to return -EAGAIN
> based on its parent class, not EAGAIN
> 
> Signed-off-by: Guoshuai Li <ligs@dtdream.com>

Thanks, applied to master.
diff mbox

Patch

diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index 4fd68f9..58c4925 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -809,7 +809,9 @@  class SSLStream(Stream):
                 buf = buf.encode('utf-8')
             return super(SSLStream, self).send(buf)
         except SSL.WantWriteError:
-            return errno.EAGAIN
+            return -errno.EAGAIN
+        except SSL.SysCallError as e:
+            return -ovs.socket_util.get_exception_errno(e)
 
 
 if SSL: