From 7b3c1631d1beb784b0c4294f315499a17d96e1c7 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 17 Aug 2018 21:27:14 +0800 Subject: [PATCH] more stable --- lualib/skynet/socketchannel.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lualib/skynet/socketchannel.lua b/lualib/skynet/socketchannel.lua index c11626b9c..1ebfc0475 100644 --- a/lualib/skynet/socketchannel.lua +++ b/lualib/skynet/socketchannel.lua @@ -113,7 +113,6 @@ local function dispatch_by_session(self) wakeup_all(self, errormsg) end end - self.__dispatch_thread = nil end local function pop_response(self) @@ -190,7 +189,6 @@ local function dispatch_by_order(self) wakeup_all(self, errmsg) end end - self.__dispatch_thread = nil end local function dispatch_function(self) @@ -254,7 +252,11 @@ local function connect_once(self) end self.__sock = setmetatable( {fd} , channel_socket_meta ) - self.__dispatch_thread = skynet.fork(dispatch_function(self), self) + self.__dispatch_thread = skynet.fork(function() + pcall(dispatch_function(self), self) + -- clear dispatch_thread + self.__dispatch_thread = nil + end) if self.__auth then self.__authcoroutine = coroutine.running()