]> git.pld-linux.org Git - packages/lighttpd.git/blame - lighttpd-branch.diff
- Revision 2686:
[packages/lighttpd.git] / lighttpd-branch.diff
CommitLineData
d896cce3
ER
1# Revision 2686
2Index: src/mod_rewrite.c
3===================================================================
4--- src/mod_rewrite.c (.../tags/lighttpd-1.4.24)
5+++ src/mod_rewrite.c (.../branches/lighttpd-1.4.x)
6@@ -9,10 +9,9 @@
7 #include <stdlib.h>
8 #include <string.h>
9
10-typedef struct {
11 #ifdef HAVE_PCRE_H
12+typedef struct {
13 pcre *key;
14-#endif
15
16 buffer *value;
17
18@@ -70,7 +69,6 @@
19 }
20
21 static int rewrite_rule_buffer_append(rewrite_rule_buffer *kvb, buffer *key, buffer *value, int once) {
22-#ifdef HAVE_PCRE_H
23 size_t i;
24 const char *errptr;
25 int erroff;
26@@ -109,18 +107,9 @@
27 kvb->used++;
28
29 return 0;
30-#else
31- UNUSED(kvb);
32- UNUSED(value);
33- UNUSED(once);
34- UNUSED(key);
35-
36- return -1;
37-#endif
38 }
39
40 static void rewrite_rule_buffer_free(rewrite_rule_buffer *kvb) {
41-#ifdef HAVE_PCRE_H
42 size_t i;
43
44 for (i = 0; i < kvb->size; i++) {
45@@ -130,7 +119,6 @@
46 }
47
48 if (kvb->ptr) free(kvb->ptr);
49-#endif
50
51 free(kvb);
52 }
53@@ -201,24 +189,29 @@
54 ((data_string *)(da->value->data[j]))->key,
55 ((data_string *)(da->value->data[j]))->value,
56 once)) {
57-#ifdef HAVE_PCRE_H
58 log_error_write(srv, __FILE__, __LINE__, "sb",
59 "pcre-compile failed for", da->value->data[j]->key);
60-#else
61- log_error_write(srv, __FILE__, __LINE__, "s",
62- "pcre support is missing, please install libpcre and the headers");
63-#endif
64 }
65 }
66 }
67
68 return 0;
69 }
70+#else
71+static int parse_config_entry(server *srv, array *ca, const char *option) {
72+ static int logged_message = 0;
73+ if (logged_message) return 0;
74+ if (NULL != array_get_element(ca, option)) {
75+ logged_message = 1;
76+ log_error_write(srv, __FILE__, __LINE__, "s",
77+ "pcre support is missing, please install libpcre and the headers");
78+ }
79+ return 0;
80+}
81+#endif
82
83 SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
84- plugin_data *p = p_d;
85 size_t i = 0;
86-
87 config_values_t cv[] = {
88 { "url.rewrite-repeat", NULL, T_CONFIG_LOCAL, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
89 { "url.rewrite-once", NULL, T_CONFIG_LOCAL, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
90@@ -243,33 +236,37 @@
91 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
92 };
93
94+#ifdef HAVE_PCRE_H
95+ plugin_data *p = p_d;
96+
97 if (!p) return HANDLER_ERROR;
98
99 /* 0 */
100 p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
101+#else
102+ UNUSED(p_d);
103+#endif
104
105 for (i = 0; i < srv->config_context->used; i++) {
106- plugin_config *s;
107 array *ca;
108+#ifdef HAVE_PCRE_H
109+ plugin_config *s;
110
111 s = calloc(1, sizeof(plugin_config));
112 s->rewrite = rewrite_rule_buffer_init();
113 s->rewrite_NF = rewrite_rule_buffer_init();
114-
115- cv[0].destination = s->rewrite;
116- cv[1].destination = s->rewrite;
117- cv[2].destination = s->rewrite_NF;
118- cv[3].destination = s->rewrite_NF;
119- cv[4].destination = s->rewrite;
120- cv[5].destination = s->rewrite;
121-
122 p->config_storage[i] = s;
123+#endif
124+
125 ca = ((data_config *)srv->config_context->data[i])->value;
126
127 if (0 != config_insert_values_global(srv, ca, cv)) {
128 return HANDLER_ERROR;
129 }
130
131+#ifndef HAVE_PCRE_H
132+# define parse_config_entry(srv, ca, x, option, y) parse_config_entry(srv, ca, option)
133+#endif
134 parse_config_entry(srv, ca, s->rewrite, "url.rewrite-once", 1);
135 parse_config_entry(srv, ca, s->rewrite, "url.rewrite-final", 1);
136 parse_config_entry(srv, ca, s->rewrite_NF, "url.rewrite-if-not-file", 1);
137@@ -280,7 +277,9 @@
138
139 return HANDLER_GO_ON;
140 }
141+
142 #ifdef HAVE_PCRE_H
143+
144 #define PATCH(x) \
145 p->conf.x = s->x;
146 static int mod_rewrite_patch_connection(server *srv, connection *con, plugin_data *p) {
147@@ -330,7 +329,7 @@
148
149 return 0;
150 }
151-#endif
152+
153 URIHANDLER_FUNC(mod_rewrite_con_reset) {
154 plugin_data *p = p_d;
155
156@@ -345,7 +344,6 @@
157 }
158
159 static int process_rewrite_rules(server *srv, connection *con, plugin_data *p, rewrite_rule_buffer *kvb) {
160-#ifdef HAVE_PCRE_H
161 size_t i;
162 handler_ctx *hctx;
163
164@@ -444,19 +442,11 @@
165 }
166 #undef N
167 }
168-#else
169- UNUSED(srv);
170- UNUSED(con);
171- UNUSED(p);
172- UNUSED(hctx);
173- UNUSED(kvb);
174-#endif
175
176 return HANDLER_GO_ON;
177 }
178
179 URIHANDLER_FUNC(mod_rewrite_physical) {
180-#ifdef HAVE_PCRE_H
181 plugin_data *p = p_d;
182 handler_t r;
183 stat_cache_entry *sce;
184@@ -480,17 +470,11 @@
185 default:
186 return r;
187 }
188-#else
189- UNUSED(srv);
190- UNUSED(con);
191- UNUSED(p_d);
192-#endif
193
194 return HANDLER_GO_ON;
195 }
196
197 URIHANDLER_FUNC(mod_rewrite_uri_handler) {
198-#ifdef HAVE_PCRE_H
199 plugin_data *p = p_d;
200
201 mod_rewrite_patch_connection(srv, con, p);
202@@ -498,29 +482,27 @@
203 if (!p->conf.rewrite) return HANDLER_GO_ON;
204
205 return process_rewrite_rules(srv, con, p, p->conf.rewrite);
206-#else
207- UNUSED(srv);
208- UNUSED(con);
209- UNUSED(p_d);
210-#endif
211
212 return HANDLER_GO_ON;
213 }
214+#endif
215
216 int mod_rewrite_plugin_init(plugin *p);
217 int mod_rewrite_plugin_init(plugin *p) {
218 p->version = LIGHTTPD_VERSION_ID;
219 p->name = buffer_init_string("rewrite");
220
221+#ifdef HAVE_PCRE_H
222 p->init = mod_rewrite_init;
223 /* it has to stay _raw as we are matching on uri + querystring
224 */
225
226 p->handle_uri_raw = mod_rewrite_uri_handler;
227 p->handle_physical = mod_rewrite_physical;
228- p->set_defaults = mod_rewrite_set_defaults;
229 p->cleanup = mod_rewrite_free;
230 p->connection_reset = mod_rewrite_con_reset;
231+#endif
232+ p->set_defaults = mod_rewrite_set_defaults;
233
234 p->data = NULL;
235
236Index: src/connections.c
237===================================================================
238--- src/connections.c (.../tags/lighttpd-1.4.24)
239+++ src/connections.c (.../branches/lighttpd-1.4.x)
240@@ -1250,8 +1250,10 @@
241
242 if (b > 0) {
243 char buf[1024];
244+#if 0
245 log_error_write(srv, __FILE__, __LINE__, "sdd",
246 "CLOSE-read()", con->fd, b);
247+#endif
248
249 /* */
250 read(con->fd, buf, sizeof(buf));
251@@ -1621,8 +1623,10 @@
252 }
253 if (b > 0) {
254 char buf[1024];
255+#if 0
256 log_error_write(srv, __FILE__, __LINE__, "sdd",
257 "CLOSE-read()", con->fd, b);
258+#endif
259
260 /* */
261 read(con->fd, buf, sizeof(buf));
262Index: src/mod_rrdtool.c
263===================================================================
264--- src/mod_rrdtool.c (.../tags/lighttpd-1.4.24)
265+++ src/mod_rrdtool.c (.../branches/lighttpd-1.4.x)
266@@ -237,11 +237,11 @@
267 "not a regular file:", s->path_rrd);
268 return HANDLER_ERROR;
269 }
270- }
271
272- /* still create DB if it's empty file */
273- if (st.st_size > 0) {
274- return HANDLER_GO_ON;
275+ /* still create DB if it's empty file */
276+ if (st.st_size > 0) {
277+ return HANDLER_GO_ON;
278+ }
279 }
280
281 /* create a new one */
b4c9cd45 282Index: src/mod_magnet.c
ceb30c4b 283===================================================================
b4c9cd45
ER
284--- src/mod_magnet.c (.../tags/lighttpd-1.4.24)
285+++ src/mod_magnet.c (.../branches/lighttpd-1.4.x)
286@@ -170,6 +170,7 @@
287 return lua_gettop(L);
288 } else {
289 lua_pushvalue(L, lua_upvalueindex(1));
290+ lua_insert(L, 1);
291 lua_call(L, lua_gettop(L) - 1, LUA_MULTRET);
292 return lua_gettop(L);
293 }
294@@ -824,9 +825,36 @@
4bf6d22b 295 return 0;
4bf6d22b
ER
296 }
297
b4c9cd45
ER
298+static int traceback (lua_State *L) {
299+ if (!lua_isstring(L, 1)) /* 'message' not a string? */
300+ return 1; /* keep it intact */
301+ lua_getfield(L, LUA_GLOBALSINDEX, "debug");
302+ if (!lua_istable(L, -1)) {
303+ lua_pop(L, 1);
304+ return 1;
ceb30c4b 305+ }
b4c9cd45
ER
306+ lua_getfield(L, -1, "traceback");
307+ if (!lua_isfunction(L, -1)) {
308+ lua_pop(L, 2);
309+ return 1;
bb37cd34 310+ }
b4c9cd45
ER
311+ lua_pushvalue(L, 1); /* pass error message */
312+ lua_pushinteger(L, 2); /* skip this function and traceback */
313+ lua_call(L, 2, 1); /* call debug.traceback */
314+ return 1;
bb37cd34
ER
315+}
316+
b4c9cd45
ER
317+static int push_traceback(lua_State *L, int narg) {
318+ int base = lua_gettop(L) - narg; /* function index */
319+ lua_pushcfunction(L, traceback);
320+ lua_insert(L, base);
321+ return base;
ceb30c4b
ER
322+}
323+
b4c9cd45
ER
324 static handler_t magnet_attract(server *srv, connection *con, plugin_data *p, buffer *name) {
325 lua_State *L;
326 int lua_return_value = -1;
327+ int errfunc;
328 /* get the script-context */
ceb30c4b 329
ceb30c4b 330
b4c9cd45 331@@ -955,7 +983,9 @@
ceb30c4b 332
b4c9cd45 333 lua_setfenv(L, -2); /* on the stack should be a modified env (sp -= 1) */
ceb30c4b 334
b4c9cd45
ER
335- if (lua_pcall(L, 0, 1, 0)) {
336+ errfunc = push_traceback(L, 0);
337+ if (lua_pcall(L, 0, 1, errfunc)) {
338+ lua_remove(L, errfunc);
339 log_error_write(srv, __FILE__, __LINE__,
340 "ss",
341 "lua_pcall():",
342@@ -969,6 +999,7 @@
ceb30c4b 343
b4c9cd45 344 return HANDLER_FINISHED;
ceb30c4b 345 }
b4c9cd45 346+ lua_remove(L, errfunc);
ceb30c4b 347
b4c9cd45
ER
348 /* we should have the function-copy and the return value on the stack */
349 assert(lua_gettop(L) == 2);
ceb30c4b
ER
350Index: configure.ac
351===================================================================
ceb30c4b
ER
352Index: SConstruct
353===================================================================
354Index: NEWS
355===================================================================
b4c9cd45 356--- NEWS (.../tags/lighttpd-1.4.24)
cc37bbfb 357+++ NEWS (.../branches/lighttpd-1.4.x)
d896cce3 358@@ -3,7 +3,14 @@
ceb30c4b
ER
359 NEWS
360 ====
361
b4c9cd45
ER
362-- 1.4.24 -
363+- 1.4.25 -
364+ * mod_magnet: fix pairs() for normal tables and strings (fixes #1307)
365+ * mod_magnet: add traceback for printing lua errors
d896cce3
ER
366+ * mod_rewrite: fix compile error if compiled without pcre
367+ * disable warning "CLOSE-read" (fixes #2091)
368+ * mod_rrdtool: fix creating file if it doesn't exist (#1788)
ceb30c4b 369+
b4c9cd45
ER
370+- 1.4.24 - 2009-10-25
371 * Add T_CONFIG_INT for bigger integers from the config (needed for #1966)
372 * Use unsigned int (and T_CONFIG_INT) for max_request_size
373 * Use unsigned int for secdownload.timeout (fixes #1966)
ceb30c4b
ER
374Index: CMakeLists.txt
375===================================================================
This page took 0.362884 seconds and 4 git commands to generate.