From fe4122e5792b2c4ad834abcd0d77d056300ebf5e Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 17 Sep 2014 21:28:24 +0800 Subject: [PATCH 1/4] fix issue #171 --- lualib/snax/gateserver.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lualib/snax/gateserver.lua b/lualib/snax/gateserver.lua index fc019143..bc5f6547 100644 --- a/lualib/snax/gateserver.lua +++ b/lualib/snax/gateserver.lua @@ -96,7 +96,7 @@ function gateserver.start(handler) function MSG.error(fd, msg) if handler.error then - handler.error(fd) + handler.error(fd, msg) end close_fd(fd) end From 3074dbea0b4556163cc3c41be8c1eaa96e1b1f0c Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 18 Sep 2014 11:44:12 +0800 Subject: [PATCH 2/4] bugfix: wakeup sleep coroutine should return BREAK --- lualib/skynet.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lualib/skynet.lua b/lualib/skynet.lua index f700ba45..78f5bef9 100644 --- a/lualib/skynet.lua +++ b/lualib/skynet.lua @@ -122,7 +122,7 @@ local function dispatch_wakeup() local session = sleep_session[co] if session then session_id_coroutine[session] = "BREAK" - return suspend(co, coroutine.resume(co, true)) + return suspend(co, coroutine.resume(co, true, "BREAK")) end end end @@ -246,7 +246,8 @@ function skynet.sleep(ti) session = tonumber(session) local succ, ret = coroutine_yield("SLEEP", session) sleep_session[coroutine.running()] = nil - if ret == true then + assert(succ, ret) + if ret == "BREAK" then return "BREAK" end end From bac9348db91115454739997ef1b8b789d55b43d7 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 18 Sep 2014 16:55:26 +0800 Subject: [PATCH 3/4] bugfix: sharedatad load name --- service/sharedatad.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/sharedatad.lua b/service/sharedatad.lua index eb3346c4..c5c0c925 100644 --- a/service/sharedatad.lua +++ b/service/sharedatad.lua @@ -39,7 +39,7 @@ function CMD.new(name, t) value = t elseif dt == "string" then value = {} - local f = load(t, "=" .. name, "t", env) + local f = load(t, "=" .. name, "t", value) f() elseif dt == "nil" then value = {} From f8bf05513c8c7158f8ce7dd16407e24c75291f0e Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 18 Sep 2014 18:27:57 +0800 Subject: [PATCH 4/4] set _ENV to metatable when shadredatad read file --- service/sharedatad.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/service/sharedatad.lua b/service/sharedatad.lua index c5c0c925..40c183c4 100644 --- a/service/sharedatad.lua +++ b/service/sharedatad.lua @@ -32,15 +32,18 @@ end local CMD = {} +local env_mt = { __index = _ENV } + function CMD.new(name, t) local dt = type(t) local value if dt == "table" then value = t elseif dt == "string" then - value = {} + value = setmetatable({}, env_mt) local f = load(t, "=" .. name, "t", value) f() + setmetatable(value, nil) elseif dt == "nil" then value = {} else