From 9d3edae7976acc03facd38a97d71bb7e42a4f512 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 14 Dec 2021 17:01:50 +0800 Subject: [PATCH] Check self.__sock before dispatch, See #1513 --- lualib/skynet/socketchannel.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lualib/skynet/socketchannel.lua b/lualib/skynet/socketchannel.lua index 3054de43..251ecc28 100644 --- a/lualib/skynet/socketchannel.lua +++ b/lualib/skynet/socketchannel.lua @@ -321,7 +321,10 @@ local function connect_once(self) self.__sock = setmetatable( {fd} , channel_socket_meta ) self.__dispatch_thread = skynet.fork(function() - pcall(dispatch_function(self), self) + if self.__sock then + -- self.__sock can be false (socket closed) if error during connecting, See #1513 + pcall(dispatch_function(self), self) + end -- clear dispatch_thread self.__dispatch_thread = nil end)