[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua and multi-threaded FastCGI servers
- From: Peter Colson <pcolson@...>
- Date: Fri, 4 Mar 2005 17:35:36 +1100
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?
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
think it could be a straightforward enhancement to the fastcgi
OK - I'll look at global vars. Just out of curiosity is the Lua
per VM thing like the global variable environment apppears to be, or is
one entity accessible from all currently running VM's - which would
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
- Is LuaThreads a separate package or is it the coroutines facility
Lua for doing non-pre-emptive threading in a Lua script? Does it sit on
of Posix threads (saw references to LuaThreads on top of eCos threads
- 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
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,
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
for invoking a Lua script and not having the calling program terminate
error occurs since the C function passed to lua_cpcall will return to
function calling lua_cpcall in the event of an error?