Skip to content

Commit cd52554

Browse files
committed
add goto failed/reused_sess
1 parent 7da2126 commit cd52554

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/resty/core/socket.lua

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
221221
end
222222

223223
if rc == FFI_ERROR then
224-
if openssl_error_code[0] ~= 0 then
225-
return nil, openssl_error_code[0] .. ": " .. ffi_str(errmsg[0])
226-
end
227-
228-
return nil, ffi_str(errmsg[0])
224+
goto failed
229225
end
230226

231227
if rc == FFI_DONE then
@@ -242,11 +238,7 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
242238

243239
assert(rc == FFI_OK)
244240

245-
if session_ptr[0] == nil then
246-
return nil
247-
end
248-
249-
return ffi_gc(session_ptr[0], C.ngx_http_lua_ffi_ssl_free_session)
241+
goto reused_sess
250242
end
251243

252244
assert(rc == FFI_AGAIN)
@@ -256,6 +248,8 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
256248
rc = C.ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result(r, u,
257249
session_ptr, errmsg, openssl_error_code)
258250

251+
::failed::
252+
259253
if rc == FFI_ERROR then
260254
if openssl_error_code[0] ~= 0 then
261255
return nil, openssl_error_code[0] .. ": " .. ffi_str(errmsg[0])
@@ -270,6 +264,8 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
270264
return true
271265
end
272266

267+
::reused_sess::
268+
273269
if session_ptr[0] == nil then
274270
return nil
275271
end

0 commit comments

Comments
 (0)