From 277bc79fb7591137da43092851696348bfb5341e Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 22 Apr 2014 19:38:20 +0800 Subject: [PATCH] bugfix: profile queue accept --- lualib-src/lua-profile.c | 5 +++-- service/snaxd.lua | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lualib-src/lua-profile.c b/lualib-src/lua-profile.c index 39a13b83..e5e48131 100644 --- a/lualib-src/lua-profile.c +++ b/lualib-src/lua-profile.c @@ -93,7 +93,8 @@ lresume(lua_State *L) { } else { lua_pop(L,1); lua_pushvalue(L,1); - lua_pushnumber(L, get_time()); + double ti = get_time(); + lua_pushnumber(L, ti); lua_rawset(L, lua_upvalueindex(1)); // set start time } @@ -121,7 +122,7 @@ lyield(lua_State *L) { lua_pushthread(L); lua_pushnumber(L, ti); - lua_rawset(L, lua_upvalueindex(1)); + lua_rawset(L, lua_upvalueindex(2)); } lua_CFunction co_yield = lua_tocfunction(L, lua_upvalueindex(3)); diff --git a/service/snaxd.lua b/service/snaxd.lua index 626a3911..7783a7af 100644 --- a/service/snaxd.lua +++ b/service/snaxd.lua @@ -40,7 +40,10 @@ local function message_dispatch() if f then if method[2] == "accept" then -- no return + profile.start() local ok, data = pcall(f, table.unpack(msg)) + local ti = profile.stop() + update_stat(method[3], ti) if not ok then print(string.format("Error on [:%x] to [:%x] %s", msg.source, skynet.self(), tostring(data))) end