2 Index: 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)
21 static int rewrite_rule_buffer_append(rewrite_rule_buffer *kvb, buffer *key, buffer *value, int once) {
40 static void rewrite_rule_buffer_free(rewrite_rule_buffer *kvb) {
44 for (i = 0; i < kvb->size; i++) {
48 if (kvb->ptr) free(kvb->ptr);
54 ((data_string *)(da->value->data[j]))->key,
55 ((data_string *)(da->value->data[j]))->value,
58 log_error_write(srv, __FILE__, __LINE__, "sb",
59 "pcre-compile failed for", da->value->data[j]->key);
61 - log_error_write(srv, __FILE__, __LINE__, "s",
62 - "pcre support is missing, please install libpcre and the headers");
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)) {
76 + log_error_write(srv, __FILE__, __LINE__, "s",
77 + "pcre support is missing, please install libpcre and the headers");
83 SETDEFAULTS_FUNC(mod_rewrite_set_defaults) {
84 - plugin_data *p = p_d;
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 */
91 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
95 + plugin_data *p = p_d;
97 if (!p) return HANDLER_ERROR;
100 p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
105 for (i = 0; i < srv->config_context->used; i++) {
111 s = calloc(1, sizeof(plugin_config));
112 s->rewrite = rewrite_rule_buffer_init();
113 s->rewrite_NF = rewrite_rule_buffer_init();
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;
122 p->config_storage[i] = s;
125 ca = ((data_config *)srv->config_context->data[i])->value;
127 if (0 != config_insert_values_global(srv, ca, cv)) {
128 return HANDLER_ERROR;
132 +# define parse_config_entry(srv, ca, x, option, y) parse_config_entry(srv, ca, option)
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);
139 return HANDLER_GO_ON;
146 static int mod_rewrite_patch_connection(server *srv, connection *con, plugin_data *p) {
153 URIHANDLER_FUNC(mod_rewrite_con_reset) {
154 plugin_data *p = p_d;
159 static int process_rewrite_rules(server *srv, connection *con, plugin_data *p, rewrite_rule_buffer *kvb) {
164 @@ -444,19 +442,11 @@
176 return HANDLER_GO_ON;
179 URIHANDLER_FUNC(mod_rewrite_physical) {
181 plugin_data *p = p_d;
183 stat_cache_entry *sce;
184 @@ -480,17 +470,11 @@
194 return HANDLER_GO_ON;
197 URIHANDLER_FUNC(mod_rewrite_uri_handler) {
199 plugin_data *p = p_d;
201 mod_rewrite_patch_connection(srv, con, p);
202 @@ -498,29 +482,27 @@
203 if (!p->conf.rewrite) return HANDLER_GO_ON;
205 return process_rewrite_rules(srv, con, p, p->conf.rewrite);
212 return HANDLER_GO_ON;
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");
222 p->init = mod_rewrite_init;
223 /* it has to stay _raw as we are matching on uri + querystring
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;
232 + p->set_defaults = mod_rewrite_set_defaults;
236 Index: 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 @@
245 log_error_write(srv, __FILE__, __LINE__, "sdd",
246 "CLOSE-read()", con->fd, b);
250 read(con->fd, buf, sizeof(buf));
251 @@ -1621,8 +1623,10 @@
256 log_error_write(srv, __FILE__, __LINE__, "sdd",
257 "CLOSE-read()", con->fd, b);
261 read(con->fd, buf, sizeof(buf));
262 Index: 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;
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;
281 /* create a new one */
282 Index: src/mod_magnet.c
283 ===================================================================
284 --- src/mod_magnet.c (.../tags/lighttpd-1.4.24)
285 +++ src/mod_magnet.c (.../branches/lighttpd-1.4.x)
287 return lua_gettop(L);
289 lua_pushvalue(L, lua_upvalueindex(1));
291 lua_call(L, lua_gettop(L) - 1, LUA_MULTRET);
292 return lua_gettop(L);
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)) {
306 + lua_getfield(L, -1, "traceback");
307 + if (!lua_isfunction(L, -1)) {
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 */
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);
324 static handler_t magnet_attract(server *srv, connection *con, plugin_data *p, buffer *name) {
326 int lua_return_value = -1;
328 /* get the script-context */
333 lua_setfenv(L, -2); /* on the stack should be a modified env (sp -= 1) */
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__,
344 return HANDLER_FINISHED;
346 + lua_remove(L, errfunc);
348 /* we should have the function-copy and the return value on the stack */
349 assert(lua_gettop(L) == 2);
351 ===================================================================
353 ===================================================================
355 ===================================================================
356 --- NEWS (.../tags/lighttpd-1.4.24)
357 +++ NEWS (.../branches/lighttpd-1.4.x)
364 + * mod_magnet: fix pairs() for normal tables and strings (fixes #1307)
365 + * mod_magnet: add traceback for printing lua errors
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)
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)
374 Index: CMakeLists.txt
375 ===================================================================