httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian McCallister <>
Subject Re: mod_lua check for lua compilation error
Date Tue, 24 Mar 2009 18:57:21 GMT
On Sat, Mar 21, 2009 at 10:54 AM, Bertrand Mansion <> wrote:
> In order to be able to detect if a lua file fails to compile and get
> an informative error message like :
>  Error!
>  /web/localhost/htdocs/info.lua:174: '=' expected near '+'
> instead of :
>  Error!
>  attempt to call a nil value
> I suggest you move the load/pcall function from
> lua_vmprep:apl_get_lua_state() to mod_lua:lua_handler() and
> mod_lua:lua_request_rec_hook_harness() like in the attached patch.

I disagree with this change, but agree with the intention. We need a
good way to get compilation errors back to folks asking for the
lua_State. We could use a state flag in the vm create callback which
says what happened -- instead of just calling it with a valid
lua_State when it is created, it will be called every time, with an
enumeration of what happened, one of { create, reuse, syntax_error,
other_error } or such.

I think the lua_State may hold the compilation problems, but am not
sure, need to go poke around -- I won't have a chance for a while
still, am dealing with a family medical issue for a couple weeks
(nothing urgent, just needing attention).

> I haven't yet tested how my patch works with hooks but it seems to be
> ok for lua_handler. I am not sure about the lua_gc() in case pcall
> fails, it just seem logical and that's how it's done in Lua's lua.c
> interpreter.
> PS: I wish mod_lua was under a distributed SCM like Git or Mercurial,
> it would make things easier for me. It takes me forever to make a
> patch and I am not even sure it can be used.

Jukka maintains a git mirror of apache at


> --
> Bertrand Mansion
> Mamasam

View raw message