Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在agent服务中使用了一个local表,各种花式crash #1404

Open
FashGek opened this issue May 17, 2021 · 0 comments
Open

在agent服务中使用了一个local表,各种花式crash #1404

FashGek opened this issue May 17, 2021 · 0 comments

Comments

@FashGek
Copy link

FashGek commented May 17, 2021

agent服务,处理client的请求,

local db = {}

function REQUEST:get(args)
log(db)
print("get", args.what)
--local r = skynet.call("SIMPLEDB", "lua", "get", args.what)

--print(db[args.what])
print('----------------------')
--log(db)
return { result = "haha fake" }

end

function REQUEST:set(args)
-- local r = skynet.call("SIMPLEDB", "lua", "set", args.what, args.value)
db[args.what] = args.value;
// 就是这里了,如果不赋值就不会报crash
// 这里还有一个crash,就是把上面的get也打开,就更容易crash了
dump3

--print(db[args.what])
log(db)

end

local function request(name, args, response)

print(name, args, response)

if not env.module then 
	log('module dose not exist error')
	return nil
end

-- 我们假设每一个name都是唯一的,也许未来要写一个工具,TODO 来检测proto中的name/tag都是唯一的
for _, v in pairs(env.module) do 
	local request = v.request
	if type(request) == "table" then 
		local cb = request[name]
		if cb ~= nil and type(cb) == "function" then 
			local isok, ret = pcall(cb, '', args)
			if isok then 
				if response then 
					return response(ret)
				else
					return nil
				end
			end
		end
	end
end

return nil

dump1
dump2
dump3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant