@@ -51,7 +51,7 @@ def __getattr__(self, attr):
51
51
if attr not in ('_context' , '_sock' , '_connection' , '_makefile_refs' ):
52
52
return getattr (self ._connection , attr )
53
53
54
- def __iowait (self , io_func , * args , ** kwargs ):
54
+ def __iowait2 (self , io_func , * args , ** kwargs ):
55
55
timeout = self ._sock .gettimeout () or 0.1
56
56
fd = self ._sock .fileno ()
57
57
time_start = time .time ()
@@ -78,6 +78,30 @@ def __iowait(self, io_func, *args, **kwargs):
78
78
#xlog.exception("e:%r", e)
79
79
raise e
80
80
81
+ def __iowait (self , io_func , * args , ** kwargs ):
82
+ timeout = self ._sock .gettimeout () or 0.1
83
+ fd = self ._sock .fileno ()
84
+ time_start = time .time ()
85
+ while True :
86
+ try :
87
+ return io_func (* args , ** kwargs )
88
+ except (OpenSSL .SSL .WantReadError , OpenSSL .SSL .WantX509LookupError ):
89
+ sys .exc_clear ()
90
+ _ , _ , errors = select .select ([fd ], [], [fd ], timeout )
91
+ if errors :
92
+ break
93
+ time_now = time .time ()
94
+ if time_now - time_start > timeout :
95
+ break
96
+ except OpenSSL .SSL .WantWriteError :
97
+ sys .exc_clear ()
98
+ _ , _ , errors = select .select ([], [fd ], [fd ], timeout )
99
+ if errors :
100
+ break
101
+ time_now = time .time ()
102
+ if time_now - time_start > timeout :
103
+ break
104
+
81
105
def accept (self ):
82
106
sock , addr = self ._sock .accept ()
83
107
client = OpenSSL .SSL .Connection (sock ._context , sock )
@@ -221,20 +245,6 @@ def context_builder(ca_certs=None, cipher_suites=None):
221
245
#
222
246
if not cipher_suites :
223
247
cipher_suites = ('ALL:!RC4-SHA:!ECDHE-RSA-RC4-SHA:!ECDHE-RSA-AES128-GCM-SHA256:!AES128-GCM-SHA256' ,)
224
- """
225
- cipher_suites = (
226
- "DHE-RSA-AES256-SHA256",
227
- "DHE-RSA-AES256-SHA",
228
- "DHE-RSA-AES128-SHA",
229
- "ECDHE-ECDSA-AES256-SHA",
230
- "ECDHE-ECDSA-AES128-SHA",
231
- "ECDHE-RSA-AES128-SHA",
232
- "ECDHE-ECDSA-RC4-SHA",
233
- "AES256-SHA",
234
- "AES128-SHA",
235
- "RC4-MD5",
236
- "DES-CBC3-SHA"
237
- )"""
238
248
239
249
protocol_version = getattr (OpenSSL .SSL , '%s_METHOD' % ssl_version )
240
250
ssl_context = OpenSSL .SSL .Context (protocol_version )
0 commit comments