mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
call socket.abandon while auth error, see issue #355
This commit is contained in:
@@ -49,7 +49,6 @@ end
|
|||||||
|
|
||||||
local function launch_slave(auth_handler)
|
local function launch_slave(auth_handler)
|
||||||
local function auth(fd, addr)
|
local function auth(fd, addr)
|
||||||
fd = assert(tonumber(fd))
|
|
||||||
skynet.error(string.format("connect from %s (fd = %d)", addr, fd))
|
skynet.error(string.format("connect from %s (fd = %d)", addr, fd))
|
||||||
socket.start(fd)
|
socket.start(fd)
|
||||||
|
|
||||||
@@ -84,11 +83,11 @@ local function launch_slave(auth_handler)
|
|||||||
|
|
||||||
local ok, server, uid = pcall(auth_handler,token)
|
local ok, server, uid = pcall(auth_handler,token)
|
||||||
|
|
||||||
socket.abandon(fd)
|
|
||||||
return ok, server, uid, secret
|
return ok, server, uid, secret
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ret_pack(ok, err, ...)
|
local function ret_pack(fd, ok, err, ...)
|
||||||
|
socket.abandon(fd)
|
||||||
if ok then
|
if ok then
|
||||||
skynet.ret(skynet.pack(err, ...))
|
skynet.ret(skynet.pack(err, ...))
|
||||||
else
|
else
|
||||||
@@ -100,8 +99,12 @@ local function launch_slave(auth_handler)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
skynet.dispatch("lua", function(_,_,...)
|
skynet.dispatch("lua", function(_,_,fd,...)
|
||||||
ret_pack(pcall(auth, ...))
|
if type(fd) ~= "number" then
|
||||||
|
skynet.ret(skynet.pack(false, "invalid fd type"))
|
||||||
|
else
|
||||||
|
ret_pack(fd,pcall(auth, fd, ...))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user