This commit is contained in:
Cloud Wu
2022-06-09 08:03:58 +08:00
parent 389146167f
commit e98378e874

View File

@@ -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