lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On 04/03/2005, at 12:07 PM, Javier Guerra wrote:

On Thursday 03 March 2005 7:42 pm, Peter Colson wrote:
So the problem is that l_fcgiout() needs access to the FCGX_Request
instance set up in the FastCGI accept loop (prior to calling Lua).

What is the best way to make the FCGX_Request instance in the threaded
accept loop available to my Lua function l_fcgiout?

Should I:

a). Push it onto the stack and pop it off in l_fcgiout (along with
other parameters passed to fcgiout)?
b). Use a Lua global variable since global variables are distinct for
each Lua VM and each worker thread above creates it's own Lua VM?
c). Use the Lua registry? Is the registry a per Lua VM entity like the
global variables in b)?

i'd choose b)

have you tried LuaThreads? it'd let you do most of this in Lua, in fact i think it could be a straightforward enhancement to the fastcgi launcher of
CGILua

--
Javier


OK - I'll look at global vars. Just out of curiosity is the Lua registry a per VM thing like the global variable environment apppears to be, or is it one entity accessible from all currently running VM's - which would have an
impact on keying entries for it?

Sorry, late in the week and new to Lua so some (basic) questions
follow...I've been scanning the archives/docs but seem to be getting some info
overload...

- Is LuaThreads a separate package or is it the coroutines facility within standard Lua for doing non-pre-emptive threading in a Lua script? Does it sit on top
of Posix threads (saw references to LuaThreads on top of eCos threads
elsewhere)?

- I can see a lua_newthread() API that can be called from C - is this an
alternative to creating my own Posix thread and then lua_open()'ing a new
Lua VM within that thread (which was what I was trying to do now)?

- lua_set/gettable(L, LUA_GLOBALSINDEX) vs. lua_set/getglobal(L, "global_id")
as a way of setting/getting globals in a Lua VM. Are these equivalent or
have I confused two concepts?

- Also, lua_pcall vs. lua_cpcall. lua_cpcall seems to be the preferred method for invoking a Lua script and not having the calling program terminate if an error occurs since the C function passed to lua_cpcall will return to the
function calling lua_cpcall in the event of an error?


Regards,
Peter Colson.