From 44e6693a400641d21cc4d8ae2974a0e310b91440 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 13 Oct 2014 16:47:40 +0800 Subject: [PATCH] clear coroutine_pool when gc --- lualib/skynet.lua | 9 ++++++++- lualib/skynet/debug.lua | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lualib/skynet.lua b/lualib/skynet.lua index 03699f95..ec9258b1 100644 --- a/lualib/skynet.lua +++ b/lualib/skynet.lua @@ -709,8 +709,15 @@ function skynet.term(service) return _error_dispatch(0, service) end +local function clear_pool() + coroutine_pool = {} +end + -- Inject internal debug framework local debug = require "skynet.debug" -debug(skynet, dispatch_message) +debug(skynet, { + dispatch = dispatch_message, + clear = clear_pool, +}) return skynet diff --git a/lualib/skynet/debug.lua b/lualib/skynet/debug.lua index 4105ddcb..d834bf23 100644 --- a/lualib/skynet/debug.lua +++ b/lualib/skynet/debug.lua @@ -2,7 +2,7 @@ local io = io local table = table local debug = debug -return function (skynet, dispatch_func) +return function (skynet, export) local internal_info_func @@ -18,7 +18,7 @@ function dbgcmd.MEM() end function dbgcmd.GC() - coroutine_pool = {} + export.clear() collectgarbage "collect" end @@ -49,7 +49,7 @@ end function dbgcmd.RUN(source, filename) local inject = require "skynet.inject" - local output = inject(source, filename , dispatch_func, skynet.register_protocol) + local output = inject(source, filename , export.dispatch, skynet.register_protocol) collectgarbage "collect" skynet.ret(skynet.pack(table.concat(output, "\n"))) end