From 33a7987d96f1d1da6cfef2aba0c3d6a12ce1bb57 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 29 Feb 2012 17:46:51 +0100 Subject: ssl fix --- module/remote/thriftbackend/Socket.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'module/remote/thriftbackend') diff --git a/module/remote/thriftbackend/Socket.py b/module/remote/thriftbackend/Socket.py index 2243f9df2..c38c39198 100644 --- a/module/remote/thriftbackend/Socket.py +++ b/module/remote/thriftbackend/Socket.py @@ -8,7 +8,9 @@ from time import sleep from thrift.transport.TSocket import TSocket, TServerSocket, TTransportException -WantReadError = Exception #overwritten when ssl is used +#overwritten when ssl is used +WantReadError = None +WantWriteError = None class SecureSocketConnection: def __init__(self, connection): @@ -30,14 +32,14 @@ class SecureSocketConnection: def send(self, buff): try: return self.__dict__["connection"].send(buff) - except WantReadError: + except (WantReadError, WantWriteError): sleep(0.1) return self.send(buff) def recv(self, buff): try: return self.__dict__["connection"].recv(buff) - except WantReadError: + except (WantReadError, WantWriteError): sleep(0.1) return self.recv(buff) @@ -47,9 +49,13 @@ class Socket(TSocket): self.ssl = ssl def open(self): + global WantReadError, WantWriteError + if self.ssl: SSL = __import__("OpenSSL", globals(), locals(), "SSL", -1).SSL WantReadError = SSL.WantReadError + WantWriteError = SSL.WantWriteError + ctx = SSL.Context(SSL.SSLv23_METHOD) c = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) c.set_connect_state() -- cgit v1.2.3