Bug #2674
closedAdd Lua 5.2 support
Description
I'm a Lighttpd maintainer for FreeBSD and I'm currently trying to make Lighttpd use Lua 5.2. For now, I've got a following patch:
--- src/mod_magnet.c.orig 2015-08-29 14:22:38.000000000 +0200 +++ src/mod_magnet.c 2015-09-29 11:46:30.312599419 +0200 @@ -24,6 +24,10 @@ #define MAGNET_CONFIG_PHYSICAL_PATH "magnet.attract-physical-path-to" #define MAGNET_RESTART_REQUEST 99 +#if LUA_VERSION_NUM >= 502 +#define LUA_GLOBALSINDEX LUA_REGISTRYINDEX +#endif + /* plugin config for all request/connections */ static jmp_buf exceptionjmp; @@ -688,7 +692,11 @@ * get the environment of the function */ +#if LUA_VERSION_NUM >= 502 + lua_getuservalue(L, -1); /* -1 is the function */ +#else lua_getfenv(L, -1); /* -1 is the function */ +#endif /* lighty.header */ @@ -738,7 +746,11 @@ */ force_assert(lua_isfunction(L, -1)); +#if LUA_VERSION_NUM >= 502 + lua_getuservalue(L, -1); /* -1 is the function */ +#else lua_getfenv(L, -1); /* -1 is the function */ +#endif lua_getfield(L, -1, "lighty"); /* lighty.* from the env */ force_assert(lua_istable(L, -1)); @@ -988,7 +1000,11 @@ lua_setmetatable(L, -2); /* setmetatable({}, {__index = _G}) (sp -= 1) */ +#if LUA_VERSION_NUM >= 502 + lua_setuservalue(L, -2); /* on the stack should be a modified env (sp -= 1) */ +#else lua_setfenv(L, -2); /* on the stack should be a modified env (sp -= 1) */ +#endif errfunc = push_traceback(L, 0); if (lua_pcall(L, 0, 1, errfunc)) {
For now it compiles and after enabling mod_magnet Lighttpd starts fine, but using Lua makes Lighttpd return 503.
Files
Updated by stbuehler about 9 years ago
Can you please test the patch at https://review.lighttpd.net/D4 ?
Updated by pkubaj about 9 years ago
stbuehler wrote:
Can you please test the patch at https://review.lighttpd.net/D4 ?
The patching fails with:
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|--- a/src/CMakeLists.txt
|+++ b/src/CMakeLists.txt
--------------------------
Patching file CMakeLists.txt using Plan A...
No such line 396 in input file, ignoring
Hunk #1 failed at 397.
1 out of 1 hunks failed--saving rejects to CMakeLists.txt.rej
Updated by pkubaj about 9 years ago
Sorry, it works using svn patch instead of patch.
Updated by stbuehler about 9 years ago
- Target version changed from 1.4.38 to 1.4.39
Updated by stbuehler almost 9 years ago
- Target version changed from 1.4.39 to 1.4.40
Updated by stbuehler almost 9 years ago
- Status changed from New to Fixed
- % Done changed from 0 to 100
Applied in changeset r3070.
Updated by stbuehler almost 9 years ago
- Has duplicate Bug #2421: lighttpd 1.4.31 is not compatible with lua 5.2.1 added
Also available in: Atom