@@ -220,49 +220,43 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
220
220
error (" no request ctx found" , 2 )
221
221
end
222
222
223
- if rc == FFI_ERROR then
224
- goto failed
225
- end
223
+ while true do
224
+ if rc == FFI_ERROR then
225
+ if openssl_error_code [0 ] ~= 0 then
226
+ return nil , openssl_error_code [0 ] .. " : " .. ffi_str (errmsg [0 ])
227
+ end
226
228
227
- if rc == FFI_DONE then
228
- return reused_session
229
- end
229
+ return nil , ffi_str (errmsg [0 ])
230
+ end
230
231
231
- if rc == FFI_OK and reused_session == false then
232
- return true
233
- end
232
+ if rc == FFI_DONE then
233
+ return reused_session
234
+ end
234
235
235
- if rc == FFI_AGAIN then
236
- co_yield ()
237
- end
236
+ if rc == FFI_OK then
237
+ if reused_session == false then
238
+ return true
239
+ end
238
240
239
- -- (rc == FFI_OK and reused_session ~= false) or
240
- -- (rc == FFI_AGAIN and reused_session == cdata/false then co_yield )
241
+ rc = C . ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result ( r , u ,
242
+ session_ptr , errmsg , openssl_error_code )
241
243
242
- rc = C .ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result (r , u ,
243
- session_ptr , errmsg , openssl_error_code )
244
+ assert (rc == FFI_OK )
244
245
245
- if rc == FFI_OK then
246
- if reused_session == false then
247
- return true
248
- end
246
+ if session_ptr [0 ] == nil then
247
+ return session_ptr [0 ]
248
+ end
249
249
250
- if session_ptr [0 ] == nil then
251
- return session_ptr [0 ]
250
+ return ffi_gc (session_ptr [0 ], C .ngx_http_lua_ffi_ssl_free_session )
252
251
end
253
252
254
- return ffi_gc (session_ptr [0 ], C .ngx_http_lua_ffi_ssl_free_session )
255
- end
256
-
257
- :: failed::
253
+ assert (rc == FFI_AGAIN )
258
254
259
- assert ( rc == FFI_ERROR )
255
+ co_yield ( )
260
256
261
- if openssl_error_code [ 0 ] ~= 0 then
262
- return nil , openssl_error_code [ 0 ] .. " : " .. ffi_str ( errmsg [ 0 ] )
257
+ rc = C . ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result ( r , u ,
258
+ session_ptr , errmsg , openssl_error_code )
263
259
end
264
-
265
- return nil , ffi_str (errmsg [0 ])
266
260
end
267
261
268
262
0 commit comments