From e98378e874690d9f6bb34deda5f48bf7561238ba Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 9 Jun 2022 08:03:58 +0800 Subject: [PATCH] Fix #1609 --- lualib/snax/msgserver.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lualib/snax/msgserver.lua b/lualib/snax/msgserver.lua index 4c6f1724..5ce9c0e7 100644 --- a/lualib/snax/msgserver.lua +++ b/lualib/snax/msgserver.lua @@ -100,8 +100,10 @@ function server.logout(username) local u = user_online[username] user_online[username] = nil if u.fd then - gateserver.closeclient(u.fd) - connection[u.fd] = nil + if connection[u.fd] then + gateserver.closeclient(u.fd) + connection[u.fd] = nil + end end end @@ -153,11 +155,15 @@ function server.start(conf) handshake[fd] = nil local c = connection[fd] if c then - c.fd = nil - connection[fd] = nil if conf.disconnect_handler then conf.disconnect_handler(c.username) end + -- double check, conf.disconnect_handler may close fd + if connection[fd] then + c.fd = nil + connection[fd] = nil + gateserver.closeclient(fd) + end end end