From 43225367fbdd7034b92138c72122d0f383626a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E4=BB=94?= <41766775+huahua132@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:36:11 +0800 Subject: [PATCH] =?UTF-8?q?fix=20websocket=E5=AE=A2=E6=88=B7=E7=AB=AF?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E8=BF=87=E7=A8=8B=E4=B8=AD=E6=8F=A1=E6=89=8B?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=AF=BC=E8=87=B4=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=20(#1899)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix word err * fix word err * 增加mongo update 测试 * remove unused local variable * fix websocket客户端连接过程中握手失败导致内存泄漏 --- lualib/http/websocket.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lualib/http/websocket.lua b/lualib/http/websocket.lua index 431fc0ec..163d3d8b 100755 --- a/lualib/http/websocket.lua +++ b/lualib/http/websocket.lua @@ -14,6 +14,7 @@ local pairs = pairs local error = error local string = string local xpcall = xpcall +local pcall = pcall local debug = debug local table = table local tonumber = tonumber @@ -481,7 +482,12 @@ function M.connect(url, header, timeout) local socket_id = sockethelper.connect(host_addr, host_port, timeout) local ws_obj = _new_client_ws(socket_id, protocol, hostname) ws_obj.addr = host - write_handshake(ws_obj, host_addr, uri, header) + + local is_ok,err = pcall(write_handshake, ws_obj, host_addr, uri, header) + if not is_ok then + _close_websocket(ws_obj) + error(err) + end return socket_id end