diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-03 21:16:00 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-03 21:16:00 +0100 |
commit | bfbad391533d99e072fde43c774d60c1d9f80f8e (patch) | |
tree | edf1486f47c23d9d31c06e90885a74fa9ccfaedf | |
parent | a3c6ff07cad67ec5e9d0899002710cdd73d6915f (diff) | |
download | supple-bfbad391533d99e072fde43c774d60c1d9f80f8e.tar.gz |
SUPPLE: Ensure clean_down happens on both ends
-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) |