]>
Commit | Line | Data |
---|---|---|
b4c9cd45 | 1 | Index: src/mod_magnet.c |
ceb30c4b | 2 | =================================================================== |
b4c9cd45 ER |
3 | --- src/mod_magnet.c (.../tags/lighttpd-1.4.24) |
4 | +++ src/mod_magnet.c (.../branches/lighttpd-1.4.x) | |
5 | @@ -170,6 +170,7 @@ | |
6 | return lua_gettop(L); | |
7 | } else { | |
8 | lua_pushvalue(L, lua_upvalueindex(1)); | |
9 | + lua_insert(L, 1); | |
10 | lua_call(L, lua_gettop(L) - 1, LUA_MULTRET); | |
11 | return lua_gettop(L); | |
12 | } | |
13 | @@ -824,9 +825,36 @@ | |
4bf6d22b | 14 | return 0; |
4bf6d22b ER |
15 | } |
16 | ||
b4c9cd45 ER |
17 | +static int traceback (lua_State *L) { |
18 | + if (!lua_isstring(L, 1)) /* 'message' not a string? */ | |
19 | + return 1; /* keep it intact */ | |
20 | + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); | |
21 | + if (!lua_istable(L, -1)) { | |
22 | + lua_pop(L, 1); | |
23 | + return 1; | |
ceb30c4b | 24 | + } |
b4c9cd45 ER |
25 | + lua_getfield(L, -1, "traceback"); |
26 | + if (!lua_isfunction(L, -1)) { | |
27 | + lua_pop(L, 2); | |
28 | + return 1; | |
bb37cd34 | 29 | + } |
b4c9cd45 ER |
30 | + lua_pushvalue(L, 1); /* pass error message */ |
31 | + lua_pushinteger(L, 2); /* skip this function and traceback */ | |
32 | + lua_call(L, 2, 1); /* call debug.traceback */ | |
33 | + return 1; | |
bb37cd34 ER |
34 | +} |
35 | + | |
b4c9cd45 ER |
36 | +static int push_traceback(lua_State *L, int narg) { |
37 | + int base = lua_gettop(L) - narg; /* function index */ | |
38 | + lua_pushcfunction(L, traceback); | |
39 | + lua_insert(L, base); | |
40 | + return base; | |
ceb30c4b ER |
41 | +} |
42 | + | |
b4c9cd45 ER |
43 | static handler_t magnet_attract(server *srv, connection *con, plugin_data *p, buffer *name) { |
44 | lua_State *L; | |
45 | int lua_return_value = -1; | |
46 | + int errfunc; | |
47 | /* get the script-context */ | |
ceb30c4b | 48 | |
ceb30c4b | 49 | |
b4c9cd45 | 50 | @@ -955,7 +983,9 @@ |
ceb30c4b | 51 | |
b4c9cd45 | 52 | lua_setfenv(L, -2); /* on the stack should be a modified env (sp -= 1) */ |
ceb30c4b | 53 | |
b4c9cd45 ER |
54 | - if (lua_pcall(L, 0, 1, 0)) { |
55 | + errfunc = push_traceback(L, 0); | |
56 | + if (lua_pcall(L, 0, 1, errfunc)) { | |
57 | + lua_remove(L, errfunc); | |
58 | log_error_write(srv, __FILE__, __LINE__, | |
59 | "ss", | |
60 | "lua_pcall():", | |
61 | @@ -969,6 +999,7 @@ | |
ceb30c4b | 62 | |
b4c9cd45 | 63 | return HANDLER_FINISHED; |
ceb30c4b | 64 | } |
b4c9cd45 | 65 | + lua_remove(L, errfunc); |
ceb30c4b | 66 | |
b4c9cd45 ER |
67 | /* we should have the function-copy and the return value on the stack */ |
68 | assert(lua_gettop(L) == 2); | |
ceb30c4b ER |
69 | Index: configure.ac |
70 | =================================================================== | |
ceb30c4b ER |
71 | Index: SConstruct |
72 | =================================================================== | |
73 | Index: NEWS | |
74 | =================================================================== | |
b4c9cd45 | 75 | --- NEWS (.../tags/lighttpd-1.4.24) |
cc37bbfb | 76 | +++ NEWS (.../branches/lighttpd-1.4.x) |
b4c9cd45 | 77 | @@ -3,7 +3,11 @@ |
ceb30c4b ER |
78 | NEWS |
79 | ==== | |
80 | ||
b4c9cd45 ER |
81 | -- 1.4.24 - |
82 | +- 1.4.25 - | |
83 | + * mod_magnet: fix pairs() for normal tables and strings (fixes #1307) | |
84 | + * mod_magnet: add traceback for printing lua errors | |
ceb30c4b | 85 | + |
b4c9cd45 ER |
86 | +- 1.4.24 - 2009-10-25 |
87 | * Add T_CONFIG_INT for bigger integers from the config (needed for #1966) | |
88 | * Use unsigned int (and T_CONFIG_INT) for max_request_size | |
89 | * Use unsigned int for secdownload.timeout (fixes #1966) | |
ceb30c4b ER |
90 | Index: CMakeLists.txt |
91 | =================================================================== |