diff options
-rw-r--r-- | lib/supple/host.lua | 4 | ||||
-rw-r--r-- | lib/supple/objects.lua | 6 | ||||
-rw-r--r-- | 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) |