Project

General

Profile

Actions

Bug #2674

closed

Add Lua 5.2 support

Added by pkubaj about 6 years ago. Updated almost 6 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_magnet
Target version:
ASK QUESTIONS IN Forums:

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

patch-src_mod__magnet.c (1.31 KB) patch-src_mod__magnet.c pkubaj, 2015-09-29 10:01

Related issues

Has duplicate Bug #2421: lighttpd 1.4.31 is not compatible with lua 5.2.1Duplicate2012-06-26Actions
Actions #1

Updated by stbuehler about 6 years ago

  • Description updated (diff)
Actions #2

Updated by stbuehler about 6 years ago

Can you please test the patch at https://review.lighttpd.net/D4 ?

Actions #3

Updated by pkubaj almost 6 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

Actions #4

Updated by pkubaj almost 6 years ago

Sorry, it works using svn patch instead of patch.

Actions #5

Updated by stbuehler almost 6 years ago

  • Target version changed from 1.4.38 to 1.4.39
Actions #6

Updated by stbuehler almost 6 years ago

  • Target version changed from 1.4.39 to 1.4.40
Actions #7

Updated by stbuehler almost 6 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

Applied in changeset r3070.

Actions #8

Updated by stbuehler over 5 years ago

  • Has duplicate Bug #2421: lighttpd 1.4.31 is not compatible with lua 5.2.1 added
Actions

Also available in: Atom