From d6f265e70346425f6fce5961341c2824e47ba5df Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Sat, 26 May 2018 17:37:19 +0800 Subject: [PATCH] call skynet.trace() in example --- examples/agent.lua | 6 +++++- lualib/skynet.lua | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/agent.lua b/examples/agent.lua index 3e164bb8..a27645a0 100644 --- a/examples/agent.lua +++ b/examples/agent.lua @@ -50,7 +50,10 @@ skynet.register_protocol { unpack = function (msg, sz) return host:dispatch(msg, sz) end, - dispatch = function (_, _, type, ...) + dispatch = function (fd, _, type, ...) + assert(fd == client_fd) -- You can use fd to reply message + skynet.ignoreret() -- session is fd, don't call skynet.ret + skynet.trace() if type == "REQUEST" then local ok, result = pcall(request, ...) if ok then @@ -92,6 +95,7 @@ end skynet.start(function() skynet.dispatch("lua", function(_,_, command, ...) + skynet.trace() local f = CMD[command] skynet.ret(skynet.pack(f(...))) end) diff --git a/lualib/skynet.lua b/lualib/skynet.lua index be009d15..6cdfe11b 100644 --- a/lualib/skynet.lua +++ b/lualib/skynet.lua @@ -265,6 +265,8 @@ function suspend(co, result, command, param, param2) return suspend(co, coroutine_resume(co, response)) elseif command == "EXIT" then -- coroutine exit + local tag = session_coroutine_tracetag[co] + if tag then c.trace(tag, "end") end local address = session_coroutine_address[co] if address then release_watching(address)