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 --- CHANGES | 4 ++++ Makefile | 6 +++++- tests/appendud.lua | 6 +++--- tests/errhangtest.lua | 13 +++++++++++++ tests/irayo_closure.lua | 10 ++++++---- 5 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 tests/errhangtest.lua diff --git a/CHANGES b/CHANGES index 64de559..e9cfa25 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,10 @@ CHANGES: CHANGE X: +CHANGE 26 BGe 14-Feb-2011: + Fixed application hang-up because keeper state was not released in case of errors thrown by + inter-state data copy for unsupported types + CHANGE 25 BGe 12-Feb-2011: Changed idfunc signature and contract to clarify that fact it is not lua-callable and to be able to require the module it was exported from in the target lanes diff --git a/Makefile b/Makefile index 35870a7..f27404a 100644 --- a/Makefile +++ b/Makefile @@ -71,8 +71,9 @@ rock: #--- Testing --- # test: + $(MAKE) errhangtest $(MAKE) irayo_recursive -# $(MAKE) irayo_closure + $(MAKE) irayo_closure $(MAKE) basic $(MAKE) fifo $(MAKE) keeper @@ -141,6 +142,9 @@ irayo_closure: tests/irayo_closure.lua $(_TARGET_SO) finalizer: tests/finalizer.lua $(_TARGET_SO) $(_PREFIX) $(LUA) $< +errhangtest: tests/errhangtest.lua $(_TARGET_SO) + $(_PREFIX) $(LUA) $< + error-test: tests/error.lua $(_TARGET_SO) $(_PREFIX) $(LUA) $< 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