From bfbad391533d99e072fde43c774d60c1d9f80f8e Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 3 Aug 2012 21:16:00 +0100 Subject: SUPPLE: Ensure clean_down happens on both ends --- lib/supple/host.lua | 4 +++- lib/supple/objects.lua | 6 +++++- lib/supple/sandbox.lua | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/supple/host.lua b/lib/supple/host.lua index 1226d19..a828046 100644 --- a/lib/supple/host.lua +++ b/lib/supple/host.lua @@ -63,7 +63,9 @@ local function run_sandbox(codestr, codename, ...) -- We need to clean up, so dump all the objects func = nil - objects.clean_down() + err = nil + -- And ask the supple API to clear down too + objects.clean_down(true) comms._set_fd(-1) luxio.kill(child.pid, luxio.SIGKILL) diff --git a/lib/supple/objects.lua b/lib/supple/objects.lua index 78f5788..5aa1ec7 100644 --- a/lib/supple/objects.lua +++ b/lib/supple/objects.lua @@ -23,11 +23,15 @@ local proc_call = nil local type = capi.rawtype -local function clean_down() +local function clean_down(call_other_end) -- And force a full GC gc "collect" gc "collect" gc "collect" + -- Call the other end if needed + if call_other_end then + proc_call("supple:clean_down", "__call") + end -- And forget all our local objects my_objects_by_obj = {} my_objects_by_tag = {} diff --git a/lib/supple/sandbox.lua b/lib/supple/sandbox.lua index f096cb6..92b3afd 100644 --- a/lib/supple/sandbox.lua +++ b/lib/supple/sandbox.lua @@ -128,6 +128,7 @@ local function run() -- Pretend we've "given" the host an object called 'supple:loadstring' -- which is the loadstring/load function objects.give(wrappered_load, "supple:loadstring") + objects.give(objects.clean_down, "supple:clean_down") comms._set_fd(0) return fn(comms._wait) -- cgit v1.2.1