From afb2da4789cdaddc5a0c3c9c2d57ccd36bcc74c7 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 14 Feb 2011 21:20:24 +0100 Subject: Fixed application hang-up because keeper state was not released in case of errors thrown by inter-state data copy for unsupported types --- tests/appendud.lua | 6 +++--- tests/errhangtest.lua | 13 +++++++++++++ tests/irayo_closure.lua | 10 ++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 tests/errhangtest.lua (limited to 'tests') diff --git a/tests/appendud.lua b/tests/appendud.lua index afea0e9..65d0798 100644 --- a/tests/appendud.lua +++ b/tests/appendud.lua @@ -31,18 +31,18 @@ local _ud = { function appendud(tab, ud) -io.stderr:write "Starting" + io.stderr:write "Starting" tab:beginupdate() set_finalizer( function() tab:endupdate() end ) ud:lock() set_finalizer( function() ud:unlock() end ) for i = 1,#ud do tab[#tab+1] = ud[i] end -io.stderr:write "Ending" + io.stderr:write "Ending" return tab -- need to return 'tab' since we're running in a separate thread -- ('tab' is passed over lanes by value, not by reference) end -local t,err= lanes.gen( appendud )( _tab, _ud ) -- create & launch a thread +local t,err= lanes.gen( "io", appendud )( _tab, _ud ) -- create & launch a thread assert(t) assert(not err) diff --git a/tests/errhangtest.lua b/tests/errhangtest.lua new file mode 100644 index 0000000..ddc1bfb --- /dev/null +++ b/tests/errhangtest.lua @@ -0,0 +1,13 @@ +lanes = require('lanes') + +local linda = lanes.linda() + +local coro = coroutine.create(function() end) + +-- we are not allowed to send coroutines through a lanes +-- however, this should raise an error, not hang the program... +print( pcall(linda.send,linda, 'test', "oh boy")) +print( pcall(linda.send,linda, 'test', coro)) +res = linda:receive('test') +print( res) +-- linda:send( 'test', coro) diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua index faf08fd..3a82302 100644 --- a/tests/irayo_closure.lua +++ b/tests/irayo_closure.lua @@ -20,11 +20,13 @@ local function testrun() return true end --- Should also work without these lines, but currently doesn't (bug in Lanes, --- a function thrown over isn't connected to receiving lane's globals) +-- When some function dereferences a global key, the asssociated global in the source state +-- isn't sent over the target lane +-- therefore, the necessary functions must either be pulled as upvalues (hence locals) +-- or the globals must exist in the target lanes because the modules have been required there -- ---local print=print ---local assert=assert +local print=print +local assert=assert local function useclosurehere() assert( print ) -- cgit v1.2.3-55-g6feb