]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd-branch.diff
- up to 2620 (fcgi error diagnostic messages improved)
[packages/lighttpd.git] / lighttpd-branch.diff
1 Index: ChangeLog
2 ===================================================================
3 Index: .cvsignore
4 ===================================================================
5 Index: src/.cvsignore
6 ===================================================================
7 Index: src/configfile-glue.c
8 ===================================================================
9 --- src/configfile-glue.c       (.../tags/lighttpd-1.4.23)      (revision 2620)
10 +++ src/configfile-glue.c       (.../branches/lighttpd-1.4.x)   (revision 2620)
11 @@ -103,7 +103,6 @@
12                                         if (e != ds->value->ptr && !*e && l >=0 && l <= 65535) {
13                                                 *((unsigned short *)(cv[i].destination)) = l;
14                                                 break;
15 -
16                                         }
17                                 }
18  
19 @@ -112,10 +111,40 @@
20                                 return -1;
21                         }
22                         default:
23 -                               log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected a integer, range 0 ... 65535");
24 +                               log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected a short integer, range 0 ... 65535");
25                                 return -1;
26                         }
27                         break;
28 +               case T_CONFIG_INT:
29 +                       switch(du->type) {
30 +                       case TYPE_INTEGER: {
31 +                               data_integer *di = (data_integer *)du;
32 +
33 +                               *((unsigned int *)(cv[i].destination)) = di->value;
34 +                               break;
35 +                       }
36 +                       case TYPE_STRING: {
37 +                               data_string *ds = (data_string *)du;
38 +
39 +                               if (ds->value->ptr && *ds->value->ptr) {
40 +                                       char *e;
41 +                                       long l = strtol(ds->value->ptr, &e, 10);
42 +                                       if (e != ds->value->ptr && !*e && l >= 0) {
43 +                                               *((unsigned int *)(cv[i].destination)) = l;
44 +                                               break;
45 +                                       }
46 +                               }
47 +
48 +
49 +                               log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an integer:", cv[i].key, ds->value);
50 +
51 +                               return -1;
52 +                       }
53 +                       default:
54 +                               log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected an integer, range 0 ... 4294967295");
55 +                               return -1;
56 +                       }
57 +                       break;
58                 case T_CONFIG_BOOLEAN:
59                         if (du->type == TYPE_STRING) {
60                                 data_string *ds = (data_string *)du;
61 Index: src/mod_cgi.c
62 ===================================================================
63 --- src/mod_cgi.c       (.../tags/lighttpd-1.4.23)      (revision 2620)
64 +++ src/mod_cgi.c       (.../branches/lighttpd-1.4.x)   (revision 2620)
65 @@ -56,6 +56,7 @@
66  
67  typedef struct {
68         array *cgi;
69 +       unsigned short execute_x_only;
70  } plugin_config;
71  
72  typedef struct {
73 @@ -151,6 +152,7 @@
74  
75         config_values_t cv[] = {
76                 { "cgi.assign",                  NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },       /* 0 */
77 +               { "cgi.execute-x-only",          NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },     /* 1 */
78                 { NULL,                          NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET}
79         };
80  
81 @@ -165,8 +167,10 @@
82                 assert(s);
83  
84                 s->cgi    = array_init();
85 +               s->execute_x_only = 0;
86  
87                 cv[0].destination = s->cgi;
88 +               cv[1].destination = &(s->execute_x_only);
89  
90                 p->config_storage[i] = s;
91  
92 @@ -580,12 +584,9 @@
93  #if 0
94                                 log_error_write(srv, __FILE__, __LINE__, "sd", "(debug) cgi exited fine, pid:", pid);
95  #endif
96 -                               pid = 0;
97 -
98                                 return HANDLER_GO_ON;
99                         } else {
100                                 log_error_write(srv, __FILE__, __LINE__, "sd", "cgi died, pid:", pid);
101 -                               pid = 0;
102                                 return HANDLER_GO_ON;
103                         }
104                 }
105 @@ -1005,7 +1006,7 @@
106                         args[i++] = cgi_handler->ptr;
107                 }
108                 args[i++] = con->physical.path->ptr;
109 -               args[i++] = NULL;
110 +               args[i  ] = NULL;
111  
112                 /* search for the last / */
113                 if (NULL != (c = strrchr(con->physical.path->ptr, '/'))) {
114 @@ -1018,8 +1019,6 @@
115                         *c = '/';
116                 }
117  
118 -               openDevNull(STDERR_FILENO);
119 -
120                 /* we don't need the client socket */
121                 for (i = 3; i < 256; i++) {
122                         if (i != srv->errorlog_fd) close(i);
123 @@ -1198,6 +1197,8 @@
124  
125                         if (buffer_is_equal_string(du->key, CONST_STR_LEN("cgi.assign"))) {
126                                 PATCH(cgi);
127 +                       } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("cgi.execute-x-only"))) {
128 +                               PATCH(execute_x_only);
129                         }
130                 }
131         }
132 @@ -1220,6 +1221,7 @@
133  
134         if (HANDLER_ERROR == stat_cache_get_entry(srv, con, con->physical.path, &sce)) return HANDLER_GO_ON;
135         if (!S_ISREG(sce->st.st_mode)) return HANDLER_GO_ON;
136 +       if (p->conf.execute_x_only == 1 && (sce->st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) return HANDLER_GO_ON;
137  
138         s_len = fn->used - 1;
139  
140 Index: src/network_write.c
141 ===================================================================
142 --- src/network_write.c (.../tags/lighttpd-1.4.23)      (revision 2620)
143 +++ src/network_write.c (.../branches/lighttpd-1.4.x)   (revision 2620)
144 @@ -46,15 +46,27 @@
145                         toSend = c->mem->used - 1 - c->offset;
146  #ifdef __WIN32
147                         if ((r = send(fd, offset, toSend, 0)) < 0) {
148 -                               log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed: ", strerror(errno), fd);
149 +                               /* no error handling for windows... */
150 +                               log_error_write(srv, __FILE__, __LINE__, "ssd", "send failed: ", strerror(errno), fd);
151  
152                                 return -1;
153                         }
154  #else
155                         if ((r = write(fd, offset, toSend)) < 0) {
156 -                               log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed: ", strerror(errno), fd);
157 +                               switch (errno) {
158 +                               case EAGAIN:
159 +                               case EINTR:
160 +                                       r = 0;
161 +                                       break;
162 +                               case EPIPE:
163 +                               case ECONNRESET:
164 +                                       return -2;
165 +                               default:
166 +                                       log_error_write(srv, __FILE__, __LINE__, "ssd",
167 +                                               "write failed:", strerror(errno), fd);
168  
169 -                               return -1;
170 +                                       return -1;
171 +                               }
172                         }
173  #endif
174  
175 @@ -98,7 +110,7 @@
176                                 return -1;
177                         }
178  
179 -#if defined USE_MMAP
180 +#ifdef USE_MMAP
181                         if (MAP_FAILED == (p = mmap(0, sce->st.st_size, PROT_READ, MAP_SHARED, ifd, 0))) {
182                                 log_error_write(srv, __FILE__, __LINE__, "ss", "mmap failed: ", strerror(errno));
183  
184 @@ -109,13 +121,26 @@
185                         close(ifd);
186  
187                         if ((r = write(fd, p + offset, toSend)) <= 0) {
188 -                               log_error_write(srv, __FILE__, __LINE__, "ss", "write failed: ", strerror(errno));
189 -                               munmap(p, sce->st.st_size);
190 -                               return -1;
191 +                               switch (errno) {
192 +                               case EAGAIN:
193 +                               case EINTR:
194 +                                       r = 0;
195 +                                       break;
196 +                               case EPIPE:
197 +                               case ECONNRESET:
198 +                                       munmap(p, sce->st.st_size);
199 +                                       return -2;
200 +                               default:
201 +                                       log_error_write(srv, __FILE__, __LINE__, "ssd",
202 +                                               "write failed:", strerror(errno), fd);
203 +                                       munmap(p, sce->st.st_size);
204 +
205 +                                       return -1;
206 +                               }
207                         }
208  
209                         munmap(p, sce->st.st_size);
210 -#else
211 +#else /* USE_MMAP */
212                         buffer_prepare_copy(srv->tmp_buf, toSend);
213  
214                         lseek(ifd, offset, SEEK_SET);
215 @@ -127,12 +152,33 @@
216                         }
217                         close(ifd);
218  
219 -                       if (-1 == (r = send(fd, srv->tmp_buf->ptr, toSend, 0))) {
220 -                               log_error_write(srv, __FILE__, __LINE__, "ss", "write: ", strerror(errno));
221 +#ifdef __WIN32
222 +                       if ((r = send(fd, srv->tmp_buf->ptr, toSend, 0)) < 0) {
223 +                               /* no error handling for windows... */
224 +                               log_error_write(srv, __FILE__, __LINE__, "ssd", "send failed: ", strerror(errno), fd);
225  
226                                 return -1;
227                         }
228 -#endif
229 +#else /* __WIN32 */
230 +                       if ((r = write(fd, srv->tmp_buf->ptr, toSend)) < 0) {
231 +                               switch (errno) {
232 +                               case EAGAIN:
233 +                               case EINTR:
234 +                                       r = 0;
235 +                                       break;
236 +                               case EPIPE:
237 +                               case ECONNRESET:
238 +                                       return -2;
239 +                               default:
240 +                                       log_error_write(srv, __FILE__, __LINE__, "ssd",
241 +                                               "write failed:", strerror(errno), fd);
242 +
243 +                                       return -1;
244 +                               }
245 +                       }
246 +#endif /* __WIN32 */
247 +#endif /* USE_MMAP */
248 +
249                         c->offset += r;
250                         cq->bytes_out += r;
251  
252 Index: src/mod_secure_download.c
253 ===================================================================
254 --- src/mod_secure_download.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
255 +++ src/mod_secure_download.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
256 @@ -37,7 +37,7 @@
257         buffer *secret;
258         buffer *uri_prefix;
259  
260 -       unsigned short timeout;
261 +       unsigned int timeout;
262  } plugin_config;
263  
264  typedef struct {
265 @@ -99,7 +99,7 @@
266                 { "secdownload.secret",            NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },       /* 0 */
267                 { "secdownload.document-root",     NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },       /* 1 */
268                 { "secdownload.uri-prefix",        NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },       /* 2 */
269 -               { "secdownload.timeout",           NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 3 */
270 +               { "secdownload.timeout",           NULL, T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION },        /* 3 */
271                 { NULL,                            NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
272         };
273  
274 @@ -245,8 +245,8 @@
275         }
276  
277         /* timed-out */
278 -       if ( (srv->cur_ts > ts && srv->cur_ts - ts > p->conf.timeout) ||
279 -            (srv->cur_ts < ts && ts - srv->cur_ts > p->conf.timeout) ) {
280 +       if ( (srv->cur_ts > ts && (unsigned int) (srv->cur_ts - ts) > p->conf.timeout) ||
281 +            (srv->cur_ts < ts && (unsigned int) (ts - srv->cur_ts) > p->conf.timeout) ) {
282                 /* "Gone" as the url will never be valid again instead of "408 - Timeout" where the request may be repeated */
283                 con->http_status = 410;
284  
285 Index: src/base.h
286 ===================================================================
287 --- src/base.h  (.../tags/lighttpd-1.4.23)      (revision 2620)
288 +++ src/base.h  (.../branches/lighttpd-1.4.x)   (revision 2620)
289 @@ -84,6 +84,7 @@
290  typedef enum { T_CONFIG_UNSET,
291                 T_CONFIG_STRING,
292                 T_CONFIG_SHORT,
293 +               T_CONFIG_INT,
294                 T_CONFIG_BOOLEAN,
295                 T_CONFIG_ARRAY,
296                 T_CONFIG_LOCAL,
297 @@ -281,7 +282,7 @@
298         unsigned short etag_use_mtime;
299         unsigned short etag_use_size;
300         unsigned short force_lowercase_filenames; /* if the FS is case-insensitive, force all files to lower-case */
301 -       unsigned short max_request_size;
302 +       unsigned int max_request_size;
303  
304         unsigned short kbytes_per_second; /* connection kb/s limit */
305  
306 @@ -472,6 +473,7 @@
307  
308         buffer *errorlog_file;
309         unsigned short errorlog_use_syslog;
310 +       buffer *breakagelog_file;
311  
312         unsigned short dont_daemonize;
313         buffer *changeroot;
314 @@ -490,7 +492,7 @@
315         unsigned short max_worker;
316         unsigned short max_fds;
317         unsigned short max_conns;
318 -       unsigned short max_request_size;
319 +       unsigned int max_request_size;
320  
321         unsigned short log_request_header_on_error;
322         unsigned short log_state_handling;
323 @@ -538,7 +540,7 @@
324  
325         /* the errorlog */
326         int errorlog_fd;
327 -       enum { ERRORLOG_STDERR, ERRORLOG_FILE, ERRORLOG_SYSLOG, ERRORLOG_PIPE } errorlog_mode;
328 +       enum { ERRORLOG_FILE, ERRORLOG_FD, ERRORLOG_SYSLOG, ERRORLOG_PIPE } errorlog_mode;
329         buffer *errorlog_buf;
330  
331         fdevents *ev, *ev_ins;
332 Index: src/mod_rewrite.c
333 ===================================================================
334 --- src/mod_rewrite.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
335 +++ src/mod_rewrite.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
336 @@ -176,7 +176,7 @@
337         data_unset *du;
338  
339         if (NULL != (du = array_get_element(ca, option))) {
340 -               data_array *da = (data_array *)du;
341 +               data_array *da;
342                 size_t j;
343  
344                 if (du->type != TYPE_ARRAY) {
345 @@ -373,7 +373,7 @@
346                         }
347                 } else {
348                         const char **list;
349 -                       size_t start, end;
350 +                       size_t start;
351                         size_t k;
352  
353                         /* it matched */
354 @@ -383,17 +383,15 @@
355  
356                         buffer_reset(con->request.uri);
357  
358 -                       start = 0; end = pattern_len;
359 +                       start = 0;
360                         for (k = 0; k < pattern_len; k++) {
361                                 if (pattern[k] == '$' || pattern[k] == '%') {
362                                         /* got one */
363  
364                                         size_t num = pattern[k + 1] - '0';
365  
366 -                                       end = k;
367 +                                       buffer_append_string_len(con->request.uri, pattern + start, k - start);
368  
369 -                                       buffer_append_string_len(con->request.uri, pattern + start, end - start);
370 -
371                                         if (!isdigit((unsigned char)pattern[k + 1])) {
372                                                 /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */
373                                                 buffer_append_string_len(con->request.uri, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2);
374 Index: src/connections.c
375 ===================================================================
376 --- src/connections.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
377 +++ src/connections.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
378 @@ -782,13 +782,13 @@
379         CLEAN(request.pathinfo);
380         CLEAN(request.request);
381  
382 -       CLEAN(request.orig_uri);
383 +       /* CLEAN(request.orig_uri); */
384  
385         CLEAN(uri.scheme);
386 -       CLEAN(uri.authority);
387 -       CLEAN(uri.path);
388 +       /* CLEAN(uri.authority); */
389 +       /* CLEAN(uri.path); */
390         CLEAN(uri.path_raw);
391 -       CLEAN(uri.query);
392 +       /* CLEAN(uri.query); */
393  
394         CLEAN(physical.doc_root);
395         CLEAN(physical.path);
396 @@ -1401,6 +1401,11 @@
397                                                 "state for fd", con->fd, connection_get_state(con->state));
398                         }
399  
400 +                       buffer_reset(con->uri.authority);
401 +                       buffer_reset(con->uri.path);
402 +                       buffer_reset(con->uri.query);
403 +                       buffer_reset(con->request.orig_uri);
404 +
405                         if (http_request_parse(srv, con)) {
406                                 /* we have to read some data from the POST request */
407  
408 @@ -1725,7 +1730,7 @@
409                                 case HANDLER_FINISHED:
410                                         break;
411                                 default:
412 -                                       log_error_write(srv, __FILE__, __LINE__, "");
413 +                                       log_error_write(srv, __FILE__, __LINE__, "sd", "unhandling return value", r);
414                                         break;
415                                 }
416                                 break;
417 Index: src/network.c
418 ===================================================================
419 --- src/network.c       (.../tags/lighttpd-1.4.23)      (revision 2620)
420 +++ src/network.c       (.../branches/lighttpd-1.4.x)   (revision 2620)
421 @@ -90,6 +90,7 @@
422  
423         srv_socket = calloc(1, sizeof(*srv_socket));
424         srv_socket->fd = -1;
425 +       srv_socket->fde_ndx = -1;
426  
427         srv_socket->srv_token = buffer_init();
428         buffer_copy_string_buffer(srv_socket->srv_token, host_token);
429 @@ -103,7 +104,7 @@
430         if (NULL == (sp = strrchr(b->ptr, ':'))) {
431                 log_error_write(srv, __FILE__, __LINE__, "sb", "value of $SERVER[\"socket\"] has to be \"ip:port\".", b);
432  
433 -               return -1;
434 +               goto error_free_socket;
435         }
436  
437         host = b->ptr;
438 @@ -126,7 +127,7 @@
439         } else if (port == 0 || port > 65535) {
440                 log_error_write(srv, __FILE__, __LINE__, "sd", "port out of range:", port);
441  
442 -               return -1;
443 +               goto error_free_socket;
444         }
445  
446         if (*host == '\0') host = NULL;
447 @@ -138,12 +139,12 @@
448  
449                 if (-1 == (srv_socket->fd = socket(srv_socket->addr.plain.sa_family, SOCK_STREAM, 0))) {
450                         log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed:", strerror(errno));
451 -                       return -1;
452 +                       goto error_free_socket;
453                 }
454  #else
455                 log_error_write(srv, __FILE__, __LINE__, "s",
456                                 "ERROR: Unix Domain sockets are not supported.");
457 -               return -1;
458 +               goto error_free_socket;
459  #endif
460         }
461  
462 @@ -153,7 +154,7 @@
463  
464                 if (-1 == (srv_socket->fd = socket(srv_socket->addr.plain.sa_family, SOCK_STREAM, IPPROTO_TCP))) {
465                         log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed:", strerror(errno));
466 -                       return -1;
467 +                       goto error_free_socket;
468                 }
469                 srv_socket->use_ipv6 = 1;
470         }
471 @@ -163,17 +164,22 @@
472                 srv_socket->addr.plain.sa_family = AF_INET;
473                 if (-1 == (srv_socket->fd = socket(srv_socket->addr.plain.sa_family, SOCK_STREAM, IPPROTO_TCP))) {
474                         log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed:", strerror(errno));
475 -                       return -1;
476 +                       goto error_free_socket;
477                 }
478         }
479  
480 +#ifdef FD_CLOEXEC
481 +       /* set FD_CLOEXEC now, fdevent_fcntl_set is called later; needed for pipe-logger forks */
482 +       fcntl(srv_socket->fd, F_SETFD, FD_CLOEXEC);
483 +#endif
484 +
485         /* */
486         srv->cur_fds = srv_socket->fd;
487  
488         val = 1;
489         if (setsockopt(srv_socket->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) {
490                 log_error_write(srv, __FILE__, __LINE__, "ss", "socketsockopt failed:", strerror(errno));
491 -               return -1;
492 +               goto error_free_socket;
493         }
494  
495         switch(srv_socket->addr.plain.sa_family) {
496 @@ -198,7 +204,7 @@
497                                                 "sssss", "getaddrinfo failed: ",
498                                                 gai_strerror(r), "'", host, "'");
499  
500 -                               return -1;
501 +                               goto error_free_socket;
502                         }
503  
504                         memcpy(&(srv_socket->addr), res->ai_addr, res->ai_addrlen);
505 @@ -220,17 +226,17 @@
506                                 log_error_write(srv, __FILE__, __LINE__,
507                                                 "sds", "gethostbyname failed: ",
508                                                 h_errno, host);
509 -                               return -1;
510 +                               goto error_free_socket;
511                         }
512  
513                         if (he->h_addrtype != AF_INET) {
514                                 log_error_write(srv, __FILE__, __LINE__, "sd", "addr-type != AF_INET: ", he->h_addrtype);
515 -                               return -1;
516 +                               goto error_free_socket;
517                         }
518  
519                         if (he->h_length != sizeof(struct in_addr)) {
520                                 log_error_write(srv, __FILE__, __LINE__, "sd", "addr-length != sizeof(in_addr): ", he->h_length);
521 -                               return -1;
522 +                               goto error_free_socket;
523                         }
524  
525                         memcpy(&(srv_socket->addr.ipv4.sin_addr.s_addr), he->h_addr_list[0], he->h_length);
526 @@ -260,7 +266,7 @@
527                                 host);
528  
529  
530 -                       return -1;
531 +                       goto error_free_socket;
532                 }
533  
534                 /* connect failed */
535 @@ -275,14 +281,12 @@
536                                 "testing socket failed:",
537                                 host, strerror(errno));
538  
539 -                       return -1;
540 +                       goto error_free_socket;
541                 }
542  
543                 break;
544         default:
545 -               addr_len = 0;
546 -
547 -               return -1;
548 +               goto error_free_socket;
549         }
550  
551         if (0 != bind(srv_socket->fd, (struct sockaddr *) &(srv_socket->addr), addr_len)) {
552 @@ -298,12 +302,12 @@
553                                         host, port, strerror(errno));
554                         break;
555                 }
556 -               return -1;
557 +               goto error_free_socket;
558         }
559  
560         if (-1 == listen(srv_socket->fd, 128 * 8)) {
561                 log_error_write(srv, __FILE__, __LINE__, "ss", "listen failed: ", strerror(errno));
562 -               return -1;
563 +               goto error_free_socket;
564         }
565  
566         if (s->is_ssl) {
567 @@ -316,14 +320,14 @@
568                         if (0 == RAND_status()) {
569                                 log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
570                                                 "not enough entropy in the pool");
571 -                               return -1;
572 +                               goto error_free_socket;
573                         }
574                 }
575  
576                 if (NULL == (s->ssl_ctx = SSL_CTX_new(SSLv23_server_method()))) {
577                         log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
578                                         ERR_error_string(ERR_get_error(), NULL));
579 -                       return -1;
580 +                       goto error_free_socket;
581                 }
582  
583                 if (!s->ssl_use_sslv2) {
584 @@ -331,7 +335,7 @@
585                         if (SSL_OP_NO_SSLv2 != SSL_CTX_set_options(s->ssl_ctx, SSL_OP_NO_SSLv2)) {
586                                 log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
587                                                 ERR_error_string(ERR_get_error(), NULL));
588 -                               return -1;
589 +                               goto error_free_socket;
590                         }
591                 }
592  
593 @@ -340,33 +344,33 @@
594                         if (SSL_CTX_set_cipher_list(s->ssl_ctx, s->ssl_cipher_list->ptr) != 1) {
595                                 log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
596                                                 ERR_error_string(ERR_get_error(), NULL));
597 -                               return -1;
598 +                               goto error_free_socket;
599                         }
600                 }
601  
602                 if (buffer_is_empty(s->ssl_pemfile)) {
603                         log_error_write(srv, __FILE__, __LINE__, "s", "ssl.pemfile has to be set");
604 -                       return -1;
605 +                       goto error_free_socket;
606                 }
607  
608                 if (!buffer_is_empty(s->ssl_ca_file)) {
609                         if (1 != SSL_CTX_load_verify_locations(s->ssl_ctx, s->ssl_ca_file->ptr, NULL)) {
610                                 log_error_write(srv, __FILE__, __LINE__, "ssb", "SSL:",
611                                                 ERR_error_string(ERR_get_error(), NULL), s->ssl_ca_file);
612 -                               return -1;
613 +                               goto error_free_socket;
614                         }
615                 }
616  
617                 if (SSL_CTX_use_certificate_file(s->ssl_ctx, s->ssl_pemfile->ptr, SSL_FILETYPE_PEM) < 0) {
618                         log_error_write(srv, __FILE__, __LINE__, "ssb", "SSL:",
619                                         ERR_error_string(ERR_get_error(), NULL), s->ssl_pemfile);
620 -                       return -1;
621 +                       goto error_free_socket;
622                 }
623  
624                 if (SSL_CTX_use_PrivateKey_file (s->ssl_ctx, s->ssl_pemfile->ptr, SSL_FILETYPE_PEM) < 0) {
625                         log_error_write(srv, __FILE__, __LINE__, "ssb", "SSL:",
626                                         ERR_error_string(ERR_get_error(), NULL), s->ssl_pemfile);
627 -                       return -1;
628 +                       goto error_free_socket;
629                 }
630  
631                 if (SSL_CTX_check_private_key(s->ssl_ctx) != 1) {
632 @@ -374,7 +378,7 @@
633                                         "Private key does not match the certificate public key, reason:",
634                                         ERR_error_string(ERR_get_error(), NULL),
635                                         s->ssl_pemfile);
636 -                       return -1;
637 +                       goto error_free_socket;
638                 }
639                 SSL_CTX_set_default_read_ahead(s->ssl_ctx, 1);
640                 SSL_CTX_set_mode(s->ssl_ctx, SSL_CTX_get_mode(s->ssl_ctx) | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
641 @@ -390,7 +394,7 @@
642                 log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
643                                 "ssl requested but openssl support is not compiled in");
644  
645 -               return -1;
646 +               goto error_free_socket;
647  #endif
648  #ifdef TCP_DEFER_ACCEPT
649         } else if (s->defer_accept) {
650 @@ -414,7 +418,6 @@
651         }
652  
653         srv_socket->is_ssl = s->is_ssl;
654 -       srv_socket->fde_ndx = -1;
655  
656         if (srv->srv_sockets.size == 0) {
657                 srv->srv_sockets.size = 4;
658 @@ -430,6 +433,21 @@
659         buffer_free(b);
660  
661         return 0;
662 +
663 +error_free_socket:
664 +       if (srv_socket->fd != -1) {
665 +               /* check if server fd are already registered */
666 +               if (srv_socket->fde_ndx != -1) {
667 +                       fdevent_event_del(srv->ev, &(srv_socket->fde_ndx), srv_socket->fd);
668 +                       fdevent_unregister(srv->ev, srv_socket->fd);
669 +               }
670 +
671 +               close(srv_socket->fd);
672 +       }
673 +       buffer_free(srv_socket->srv_token);
674 +       free(srv_socket);
675 +
676 +       return -1;
677  }
678  
679  int network_close(server *srv) {
680 @@ -567,12 +585,8 @@
681                 /* not our stage */
682                 if (COMP_SERVER_SOCKET != dc->comp) continue;
683  
684 -               if (dc->cond != CONFIG_COND_EQ) {
685 -                       log_error_write(srv, __FILE__, __LINE__, "s", "only == is allowed for $SERVER[\"socket\"].");
686 +               if (dc->cond != CONFIG_COND_EQ) continue;
687  
688 -                       return -1;
689 -               }
690 -
691                 /* check if we already know this socket,
692                  * if yes, don't init it */
693                 for (j = 0; j < srv->srv_sockets.used; j++) {
694 Index: src/configfile.c
695 ===================================================================
696 --- src/configfile.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
697 +++ src/configfile.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
698 @@ -42,12 +42,12 @@
699  
700                 { "server.event-handler",        NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER },      /* 10 */
701                 { "server.pid-file",             NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER },      /* 11 */
702 -               { "server.max-request-size",     NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },   /* 12 */
703 +               { "server.max-request-size",     NULL, T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION },     /* 12 */
704                 { "server.max-worker",           NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER },       /* 13 */
705                 { "server.document-root",        NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },  /* 14 */
706 -               { "server.force-lowercase-filenames", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER },   /* 15 */
707 +               { "server.force-lowercase-filenames", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER },/* 15 */
708                 { "debug.log-condition-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER },    /* 16 */
709 -               { "server.max-keep-alive-requests", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 17 */
710 +               { "server.max-keep-alive-requests", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },/* 17 */
711                 { "server.name",                 NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },  /* 18 */
712                 { "server.max-keep-alive-idle",  NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },   /* 19 */
713  
714 @@ -91,12 +91,13 @@
715                 { "server.core-files",           NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 46 */
716                 { "ssl.cipher-list",             NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER },      /* 47 */
717                 { "ssl.use-sslv2",               NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 48 */
718 -               { "etag.use-inode",              NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 49 */
719 -               { "etag.use-mtime",              NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 50 */
720 -               { "etag.use-size",               NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 51 */
721 +               { "etag.use-inode",              NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER },     /* 49 */
722 +               { "etag.use-mtime",              NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER },     /* 50 */
723 +               { "etag.use-size",               NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER },     /* 51 */
724                 { "server.reject-expect-100-with-417",  NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 52 */
725                 { "debug.log-timeouts",          NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 53 */
726 -               { "server.defer-accept",         NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },     /* 54 */
727 +               { "server.defer-accept",         NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },   /* 54 */
728 +               { "server.breakagelog",          NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER },      /* 55 */
729                 { "server.host",                 "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
730                 { "server.docroot",              "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
731                 { "server.virtual-root",         "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
732 @@ -139,6 +140,8 @@
733         cv[43].destination = &(srv->srvconf.max_conns);
734         cv[12].destination = &(srv->srvconf.max_request_size);
735         cv[52].destination = &(srv->srvconf.reject_expect_100_with_417);
736 +       cv[55].destination = srv->srvconf.breakagelog_file;
737 +
738         srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
739  
740         assert(srv->config_storage);
741 @@ -290,6 +293,7 @@
742         PATCH(log_condition_handling);
743         PATCH(log_file_not_found);
744         PATCH(log_ssl_noise);
745 +       PATCH(log_timeouts);
746  
747         PATCH(range_requests);
748         PATCH(force_lowercase_filenames);
749 @@ -1135,15 +1139,15 @@
750                  * - select works everywhere
751                  * - linux-* are experimental
752                  */
753 +#ifdef USE_LINUX_EPOLL
754 +               { FDEVENT_HANDLER_LINUX_SYSEPOLL, "linux-sysepoll" },
755 +#endif
756  #ifdef USE_POLL
757                 { FDEVENT_HANDLER_POLL,           "poll" },
758  #endif
759  #ifdef USE_SELECT
760                 { FDEVENT_HANDLER_SELECT,         "select" },
761  #endif
762 -#ifdef USE_LINUX_EPOLL
763 -               { FDEVENT_HANDLER_LINUX_SYSEPOLL, "linux-sysepoll" },
764 -#endif
765  #ifdef USE_LINUX_SIGIO
766                 { FDEVENT_HANDLER_LINUX_RTSIG,    "linux-rtsig" },
767  #endif
768 Index: src/mod_evhost.c
769 ===================================================================
770 --- src/mod_evhost.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
771 +++ src/mod_evhost.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
772 @@ -213,7 +213,7 @@
773                 if (colon != ptr) {
774                         ds = data_string_init();
775                         buffer_copy_string_len(ds->key,CONST_STR_LEN("%"));
776 -                       buffer_append_long(ds->key, i++);
777 +                       buffer_append_long(ds->key, i /* ++ */);
778                         buffer_copy_string_len(ds->value,ptr,colon-ptr);
779  
780                         array_insert_unique(host,(data_unset *)ds);
781 @@ -294,10 +294,10 @@
782                                 char *colon = strchr(con->uri.authority->ptr, ':');
783  
784                                 if(colon == NULL) {
785 -                                       buffer_append_string_buffer(p->tmp_buf, con->uri.authority); // adds fqdn
786 +                                       buffer_append_string_buffer(p->tmp_buf, con->uri.authority); /* adds fqdn */
787                                 } else {
788                                         /* strip the port out of the authority-part of the URI scheme */
789 -                                       buffer_append_string_len(p->tmp_buf, con->uri.authority->ptr, colon - con->uri.authority->ptr); // adds fqdn
790 +                                       buffer_append_string_len(p->tmp_buf, con->uri.authority->ptr, colon - con->uri.authority->ptr); /* adds fqdn */
791                                 }
792                         } else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) {
793                                 if (ds->value->used) {
794 Index: src/splaytree.c
795 ===================================================================
796 --- src/splaytree.c     (.../tags/lighttpd-1.4.23)      (revision 2620)
797 +++ src/splaytree.c     (.../branches/lighttpd-1.4.x)   (revision 2620)
798 @@ -61,12 +61,11 @@
799   * size fields are maintained */
800  splay_tree * splaytree_splay (splay_tree *t, int i) {
801      splay_tree N, *l, *r, *y;
802 -    int comp, root_size, l_size, r_size;
803 +    int comp, l_size, r_size;
804  
805      if (t == NULL) return t;
806      N.left = N.right = NULL;
807      l = r = &N;
808 -    root_size = node_size(t);
809      l_size = r_size = 0;
810  
811      for (;;) {
812 Index: src/lemon.c
813 ===================================================================
814 --- src/lemon.c (.../tags/lighttpd-1.4.23)      (revision 2620)
815 +++ src/lemon.c (.../branches/lighttpd-1.4.x)   (revision 2620)
816 @@ -39,6 +39,12 @@
817  #   endif
818  #endif
819  
820 +#if __GNUC__ > 2
821 +#define NORETURN __attribute__ ((__noreturn__))
822 +#else
823 +#define NORETURN
824 +#endif
825 +
826  /* #define PRIVATE static */
827  #define PRIVATE static
828  
829 @@ -51,7 +57,7 @@
830  char *msort();
831  extern void *malloc();
832  
833 -extern void memory_error();
834 +extern void memory_error() NORETURN;
835  
836  /******** From the file "action.h" *************************************/
837  struct action *Action_new();
838 @@ -59,7 +65,7 @@
839  void Action_add();
840  
841  /********* From the file "assert.h" ************************************/
842 -void myassert();
843 +void myassert() NORETURN;
844  #ifndef NDEBUG
845  #  define assert(X) if(!(X))myassert(__FILE__,__LINE__)
846  #else
847 @@ -1333,7 +1339,7 @@
848  /* Report an out-of-memory condition and abort.  This function
849  ** is used mostly by the "MemoryCheck" macro in struct.h
850  */
851 -void memory_error(){
852 +void memory_error() {
853    fprintf(stderr,"Out of memory.  Aborting...\n");
854    exit(1);
855  }
856 @@ -1608,7 +1614,6 @@
857  FILE *err;
858  {
859    int spcnt, i;
860 -  spcnt = 0;
861    if( argv[0] ) fprintf(err,"%s",argv[0]);
862    spcnt = strlen(argv[0]) + 1;
863    for(i=1; i<n && argv[i]; i++){
864 @@ -2336,6 +2341,7 @@
865    if( filebuf==0 ){
866      ErrorMsg(ps.filename,0,"Can't allocate %d of memory to hold this file.",
867        filesize+1);
868 +    fclose(fp);
869      gp->errorcnt++;
870      return;
871    }
872 @@ -2343,6 +2349,7 @@
873      ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.",
874        filesize);
875      free(filebuf);
876 +    fclose(fp);
877      gp->errorcnt++;
878      return;
879    }
880 @@ -2913,7 +2920,7 @@
881   }else if( sp->destructor ){
882     cp = sp->destructor;
883     fprintf(out,"#line %d \"%s\"\n{",sp->destructorln,lemp->filename);
884 - }else if( lemp->vardest ){
885 + }else{
886     cp = lemp->vardest;
887     if( cp==0 ) return;
888     fprintf(out,"#line %d \"%s\"\n{",lemp->vardestln,lemp->filename);
889 @@ -3042,7 +3049,7 @@
890  int *plineno;               /* Pointer to the line number */
891  int mhflag;                 /* True if generating makeheaders output */
892  {
893 -  int lineno = *plineno;    /* The line number of the output */
894 +  int lineno;               /* The line number of the output */
895    char **types;             /* A hash table of datatypes */
896    int arraysize;            /* Size of the "types" array */
897    int maxdtlength;          /* Maximum length of any ".datatype" field. */
898 Index: src/mod_scgi.c
899 ===================================================================
900 --- src/mod_scgi.c      (.../tags/lighttpd-1.4.23)      (revision 2620)
901 +++ src/mod_scgi.c      (.../branches/lighttpd-1.4.x)   (revision 2620)
902 @@ -331,8 +331,21 @@
903  
904  int scgi_proclist_sort_down(server *srv, scgi_extension_host *host, scgi_proc *proc);
905  
906 +static void reset_signals(void) {
907 +#ifdef SIGTTOU
908 +       signal(SIGTTOU, SIG_DFL);
909 +#endif
910 +#ifdef SIGTTIN
911 +       signal(SIGTTIN, SIG_DFL);
912 +#endif
913 +#ifdef SIGTSTP
914 +       signal(SIGTSTP, SIG_DFL);
915 +#endif
916 +       signal(SIGHUP, SIG_DFL);
917 +       signal(SIGPIPE, SIG_DFL);
918 +       signal(SIGUSR1, SIG_DFL);
919 +}
920  
921 -
922  static handler_ctx * handler_ctx_init() {
923         handler_ctx * hctx;
924  
925 @@ -772,10 +785,8 @@
926                         env.used = 0;
927  
928                         if (scgi_fd != 0) {
929 -                               close(0);
930                                 dup2(scgi_fd, 0);
931                                 close(scgi_fd);
932 -                               scgi_fd = 0;
933                         }
934  
935                         /* we don't need the client socket */
936 @@ -783,8 +794,6 @@
937                                 close(fd);
938                         }
939  
940 -                       openDevNull(STDERR_FILENO);
941 -
942                         /* build clean environment */
943                         if (host->bin_env_copy->used) {
944                                 for (i = 0; i < host->bin_env_copy->used; i++) {
945 @@ -828,6 +837,8 @@
946                         buffer_copy_string_len(b, CONST_STR_LEN("exec "));
947                         buffer_append_string_buffer(b, host->bin_path);
948  
949 +                       reset_signals();
950 +
951                         /* exec the cgi */
952                         execle("/bin/sh", "sh", "-c", b->ptr, (char *)NULL, env.ptr);
953  
954 @@ -2163,8 +2174,11 @@
955         int ret;
956  
957         /* sanity check */
958 -       if (!host ||
959 -           ((!host->host->used || !host->port) && !host->unixsocket->used)) {
960 +       if (!host) {
961 +               log_error_write(srv, __FILE__, __LINE__, "s", "fatal error: host = NULL");
962 +               return HANDLER_ERROR;
963 +       }
964 +       if (((!host->host->used || !host->port) && !host->unixsocket->used)) {
965                 log_error_write(srv, __FILE__, __LINE__, "sxddd",
966                                 "write-req: error",
967                                 host,
968 @@ -2299,8 +2313,8 @@
969  
970                 chunkqueue_remove_finished_chunks(hctx->wb);
971  
972 -               if (-1 == ret) {
973 -                       if (errno == ENOTCONN) {
974 +               if (ret < 0) {
975 +                       if (errno == ENOTCONN || ret == -2) {
976                                 /* the connection got dropped after accept()
977                                  *
978                                  * this is most of the time a PHP which dies
979 @@ -2325,24 +2339,17 @@
980                                  */
981  
982                                 log_error_write(srv, __FILE__, __LINE__, "ssosd",
983 -                                               "[REPORT ME] connection was dropped after accept(). reconnect() denied:",
984 +                                               "connection was dropped after accept(). reconnect() denied:",
985                                                 "write-offset:", hctx->wb->bytes_out,
986                                                 "reconnect attempts:", hctx->reconnects);
987  
988                                 return HANDLER_ERROR;
989 -                       }
990 -
991 -                       if ((errno != EAGAIN) &&
992 -                           (errno != EINTR)) {
993 -
994 +                       } else {
995 +                               /* -1 == ret => error on our side */
996                                 log_error_write(srv, __FILE__, __LINE__, "ssd",
997 -                                               "write failed:", strerror(errno), errno);
998 +                                       "write failed:", strerror(errno), errno);
999  
1000                                 return HANDLER_ERROR;
1001 -                       } else {
1002 -                               fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
1003 -
1004 -                               return HANDLER_WAIT_FOR_EVENT;
1005                         }
1006                 }
1007  
1008 @@ -2469,12 +2476,10 @@
1009  }
1010  
1011  static handler_t scgi_connection_close(server *srv, handler_ctx *hctx) {
1012 -       plugin_data *p;
1013         connection  *con;
1014  
1015         if (NULL == hctx) return HANDLER_GO_ON;
1016  
1017 -       p    = hctx->plugin_data;
1018         con  = hctx->remote_conn;
1019  
1020         log_error_write(srv, __FILE__, __LINE__, "ssdsd",
1021 @@ -2724,27 +2729,29 @@
1022         /* check if extension matches */
1023         for (k = 0; k < p->conf.exts->used; k++) {
1024                 size_t ct_len;
1025 +               scgi_extension *ext = p->conf.exts->exts[k];
1026  
1027 -               extension = p->conf.exts->exts[k];
1028 +               if (ext->key->used == 0) continue;
1029  
1030 -               if (extension->key->used == 0) continue;
1031 +               ct_len = ext->key->used - 1;
1032  
1033 -               ct_len = extension->key->used - 1;
1034 -
1035                 if (s_len < ct_len) continue;
1036  
1037                 /* check extension in the form "/scgi_pattern" */
1038 -               if (*(extension->key->ptr) == '/') {
1039 -                       if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0)
1040 +               if (*(ext->key->ptr) == '/') {
1041 +                       if (strncmp(fn->ptr, ext->key->ptr, ct_len) == 0) {
1042 +                               extension = ext;
1043                                 break;
1044 -               } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
1045 +                       }
1046 +               } else if (0 == strncmp(fn->ptr + s_len - ct_len, ext->key->ptr, ct_len)) {
1047                         /* check extension in the form ".fcg" */
1048 +                       extension = ext;
1049                         break;
1050                 }
1051         }
1052  
1053         /* extension doesn't match */
1054 -       if (k == p->conf.exts->used) {
1055 +       if (NULL == extension) {
1056                 return HANDLER_GO_ON;
1057         }
1058  
1059 Index: src/mod_mysql_vhost.c
1060 ===================================================================
1061 --- src/mod_mysql_vhost.c       (.../tags/lighttpd-1.4.23)      (revision 2620)
1062 +++ src/mod_mysql_vhost.c       (.../branches/lighttpd-1.4.x)   (revision 2620)
1063 @@ -259,8 +259,14 @@
1064  
1065  #define FOO(x) (s->x->used ? s->x->ptr : NULL)
1066  
1067 +#if MYSQL_VERSION_ID >= 40100
1068 +                        /* CLIENT_MULTI_STATEMENTS first appeared in 4.1 */ 
1069                         if (!mysql_real_connect(s->mysql, FOO(hostname), FOO(myuser), FOO(mypass),
1070 +                                               FOO(mydb), s->port, FOO(mysock), CLIENT_MULTI_STATEMENTS)) {
1071 +#else
1072 +                       if (!mysql_real_connect(s->mysql, FOO(hostname), FOO(myuser), FOO(mypass),
1073                                                 FOO(mydb), s->port, FOO(mysock), 0)) {
1074 +#endif
1075                                 log_error_write(srv, __FILE__, __LINE__, "s", mysql_error(s->mysql));
1076  
1077                                 return HANDLER_ERROR;
1078 @@ -369,6 +375,9 @@
1079         if (!row || cols < 1) {
1080                 /* no such virtual host */
1081                 mysql_free_result(result);
1082 +#if MYSQL_VERSION_ID >= 40100
1083 +               while (mysql_next_result(p->conf.mysql) == 0);
1084 +#endif
1085                 return HANDLER_GO_ON;
1086         }
1087  
1088 @@ -402,6 +411,9 @@
1089                 c->fcgi_offset = c->fcgi_arg->used = 0;
1090         }
1091         mysql_free_result(result);
1092 +#if MYSQL_VERSION_ID >= 40100
1093 +       while (mysql_next_result(p->conf.mysql) == 0);
1094 +#endif
1095  
1096         /* fix virtual server and docroot */
1097  GO_ON: buffer_copy_string_buffer(con->server_name, c->server_name);
1098 @@ -416,6 +428,9 @@
1099         return HANDLER_GO_ON;
1100  
1101  ERR500:        if (result) mysql_free_result(result);
1102 +#if MYSQL_VERSION_ID >= 40100
1103 +       while (mysql_next_result(p->conf.mysql) == 0);
1104 +#endif
1105         con->http_status = 500; /* Internal Error */
1106         con->mode = DIRECT;
1107         return HANDLER_FINISHED;
1108 @@ -424,15 +439,15 @@
1109  /* this function is called at dlopen() time and inits the callbacks */
1110  int mod_mysql_vhost_plugin_init(plugin *p);
1111  int mod_mysql_vhost_plugin_init(plugin *p) {
1112 -       p->version     = LIGHTTPD_VERSION_ID;
1113 -       p->name                         = buffer_init_string("mysql_vhost");
1114 +       p->version        = LIGHTTPD_VERSION_ID;
1115 +       p->name           = buffer_init_string("mysql_vhost");
1116  
1117 -       p->init                         = mod_mysql_vhost_init;
1118 -       p->cleanup                      = mod_mysql_vhost_cleanup;
1119 -       p->handle_request_done          = mod_mysql_vhost_handle_connection_close;
1120 +       p->init           = mod_mysql_vhost_init;
1121 +       p->cleanup        = mod_mysql_vhost_cleanup;
1122 +       p->connection_reset = mod_mysql_vhost_handle_connection_close;
1123  
1124 -       p->set_defaults                 = mod_mysql_vhost_set_defaults;
1125 -       p->handle_docroot               = mod_mysql_vhost_handle_docroot;
1126 +       p->set_defaults   = mod_mysql_vhost_set_defaults;
1127 +       p->handle_docroot = mod_mysql_vhost_handle_docroot;
1128  
1129         return 0;
1130  }
1131 @@ -441,7 +456,7 @@
1132  int mod_mysql_vhost_plugin_init(plugin *p);
1133  int mod_mysql_vhost_plugin_init(plugin *p) {
1134         p->version     = LIGHTTPD_VERSION_ID;
1135 -       p->name                         = buffer_init_string("mysql_vhost");
1136 +       p->name        = buffer_init_string("mysql_vhost");
1137  
1138         return 0;
1139  }
1140 Index: src/request.c
1141 ===================================================================
1142 --- src/request.c       (.../tags/lighttpd-1.4.23)      (revision 2620)
1143 +++ src/request.c       (.../branches/lighttpd-1.4.x)   (revision 2620)
1144 @@ -111,7 +111,7 @@
1145  
1146                                         /* check the first character at right of the dot */
1147                                         if (is_ip == 0) {
1148 -                                               if (!light_isalpha(host->ptr[i+1])) {
1149 +                                               if (!light_isalnum(host->ptr[i+1])) {
1150                                                         return -1;
1151                                                 }
1152                                         } else if (!light_isdigit(host->ptr[i+1])) {
1153 @@ -133,7 +133,7 @@
1154                                 }
1155                         } else if (i == 0) {
1156                                 /* the first character of the hostname */
1157 -                               if (!light_isalpha(c)) {
1158 +                               if (!light_isalnum(c)) {
1159                                         return -1;
1160                                 }
1161                                 label_len++;
1162 @@ -540,8 +540,8 @@
1163                 con->response.keep_alive = 0;
1164                 con->keep_alive = 0;
1165  
1166 -               log_error_write(srv, __FILE__, __LINE__, "s", "no uri specified -> 400");
1167                 if (srv->srvconf.log_request_header_on_error) {
1168 +                       log_error_write(srv, __FILE__, __LINE__, "s", "no uri specified -> 400");
1169                         log_error_write(srv, __FILE__, __LINE__, "Sb",
1170                                                         "request-header:\n",
1171                                                         con->request.request);
1172 Index: src/network_backends.h
1173 ===================================================================
1174 --- src/network_backends.h      (.../tags/lighttpd-1.4.23)      (revision 2620)
1175 +++ src/network_backends.h      (.../branches/lighttpd-1.4.x)   (revision 2620)
1176 @@ -45,6 +45,11 @@
1177  
1178  #include "base.h"
1179  
1180 +/* return values:
1181 + * >= 0 : chunks completed
1182 + *   -1 : error (on our side)
1183 + *   -2 : remote close
1184 + */
1185  
1186  int network_write_chunkqueue_write(server *srv, connection *con, int fd, chunkqueue *cq);
1187  int network_write_chunkqueue_writev(server *srv, connection *con, int fd, chunkqueue *cq);
1188 Index: src/mod_rrdtool.c
1189 ===================================================================
1190 --- src/mod_rrdtool.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
1191 +++ src/mod_rrdtool.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
1192 @@ -139,10 +139,8 @@
1193  
1194                 args[i++] = p->conf.path_rrdtool_bin->ptr;
1195                 args[i++] = dash;
1196 -               args[i++] = NULL;
1197 +               args[i  ] = NULL;
1198  
1199 -               openDevNull(STDERR_FILENO);
1200 -
1201                 /* we don't need the client socket */
1202                 for (i = 3; i < 256; i++) {
1203                         close(i);
1204 @@ -268,7 +266,7 @@
1205                 "RRA:MIN:0.5:24:775 "
1206                 "RRA:MIN:0.5:288:797\n"));
1207  
1208 -       if (-1 == (r = safe_write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) {
1209 +       if (-1 == (safe_write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) {
1210                 log_error_write(srv, __FILE__, __LINE__, "ss",
1211                         "rrdtool-write: failed", strerror(errno));
1212  
1213 Index: src/stat_cache.c
1214 ===================================================================
1215 --- src/stat_cache.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
1216 +++ src/stat_cache.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
1217 @@ -503,12 +503,10 @@
1218         }
1219  
1220         if (NULL == sce) {
1221 -               int osize = 0;
1222 +#ifdef DEBUG_STAT_CACHE
1223 +               int osize = splaytree_size(sc->files);
1224 +#endif
1225  
1226 -               if (sc->files) {
1227 -                       osize = sc->files->size;
1228 -               }
1229 -
1230                 sce = stat_cache_entry_init();
1231                 buffer_copy_string_buffer(sce->name, name);
1232  
1233 Index: src/mod_proxy.c
1234 ===================================================================
1235 --- src/mod_proxy.c     (.../tags/lighttpd-1.4.23)      (revision 2620)
1236 +++ src/mod_proxy.c     (.../branches/lighttpd-1.4.x)   (revision 2620)
1237 @@ -756,12 +756,15 @@
1238  
1239         switch(hctx->state) {
1240         case PROXY_STATE_INIT:
1241 +#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
1242                 if (strstr(host->host->ptr,":")) {
1243                     if (-1 == (hctx->fd = socket(AF_INET6, SOCK_STREAM, 0))) {
1244                         log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
1245                         return HANDLER_ERROR;
1246                     }
1247 -               } else {
1248 +               } else
1249 +#endif
1250 +               {
1251                     if (-1 == (hctx->fd = socket(AF_INET, SOCK_STREAM, 0))) {
1252                         log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
1253                         return HANDLER_ERROR;
1254 @@ -842,17 +845,14 @@
1255  
1256                 chunkqueue_remove_finished_chunks(hctx->wb);
1257  
1258 -               if (-1 == ret) {
1259 -                       if (errno != EAGAIN &&
1260 -                           errno != EINTR) {
1261 -                               log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed:", strerror(errno), errno);
1262 +               if (-1 == ret) { /* error on our side */
1263 +                       log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed:", strerror(errno), errno);
1264  
1265 -                               return HANDLER_ERROR;
1266 -                       } else {
1267 -                               fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
1268 +                       return HANDLER_WAIT_FOR_EVENT;
1269 +               } else if (-2 == ret) { /* remote close */
1270 +                       log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed, remote connection close:", strerror(errno), errno);
1271  
1272 -                               return HANDLER_WAIT_FOR_EVENT;
1273 -                       }
1274 +                       return HANDLER_WAIT_FOR_EVENT;
1275                 }
1276  
1277                 if (hctx->wb->bytes_out == hctx->wb->bytes_in) {
1278 @@ -1107,19 +1107,20 @@
1279  
1280         /* check if extension matches */
1281         for (k = 0; k < p->conf.extensions->used; k++) {
1282 +               data_array *ext = NULL;
1283                 size_t ct_len;
1284  
1285 -               extension = (data_array *)p->conf.extensions->data[k];
1286 +               ext = (data_array *)p->conf.extensions->data[k];
1287  
1288 -               if (extension->key->used == 0) continue;
1289 +               if (ext->key->used == 0) continue;
1290  
1291 -               ct_len = extension->key->used - 1;
1292 +               ct_len = ext->key->used - 1;
1293  
1294                 if (s_len < ct_len) continue;
1295  
1296                 /* check extension in the form "/proxy_pattern" */
1297 -               if (*(extension->key->ptr) == '/') {
1298 -                       if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
1299 +               if (*(ext->key->ptr) == '/') {
1300 +                       if (strncmp(fn->ptr, ext->key->ptr, ct_len) == 0) {
1301                                 if (s_len > ct_len + 1) {
1302                                         char *pi_offset;
1303  
1304 @@ -1127,15 +1128,17 @@
1305                                                 path_info_offset = pi_offset - fn->ptr;
1306                                         }
1307                                 }
1308 +                               extension = ext;
1309                                 break;
1310                         }
1311 -               } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
1312 +               } else if (0 == strncmp(fn->ptr + s_len - ct_len, ext->key->ptr, ct_len)) {
1313                         /* check extension in the form ".fcg" */
1314 +                       extension = ext;
1315                         break;
1316                 }
1317         }
1318  
1319 -       if (k == p->conf.extensions->used) {
1320 +       if (NULL == extension) {
1321                 return HANDLER_GO_ON;
1322         }
1323  
1324 Index: src/Makefile.am
1325 ===================================================================
1326 --- src/Makefile.am     (.../tags/lighttpd-1.4.23)      (revision 2620)
1327 +++ src/Makefile.am     (.../branches/lighttpd-1.4.x)   (revision 2620)
1328 @@ -13,14 +13,14 @@
1329  versionstamp:
1330         @test -f versionstamp.h || touch versionstamp.h; \
1331         REVISION=""; \
1332 -       if test -x "`which svnversion`"; then \
1333 -               REVISION="$$(LANG=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)"; \
1334 +       if test -d "$(top_srcdir)/.svn" -a -x "`which svnversion`"; then \
1335 +               REVISION="$$(LANG= LC_ALL=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)"; \
1336                 if test "$$REVISION" = "exported"; then \
1337                         REVISION=""; \
1338                 fi; \
1339         fi; \
1340         if test -z "$$REVISION" -a -x "`which git`"; then \
1341 -               REVISION="$$(cd "$(top_srcdir)"; LANG=C git describe --always 2>/dev/null || echo)"; \
1342 +               REVISION="$$(cd "$(top_srcdir)"; LANG= LC_ALL=C git describe --always 2>/dev/null || echo)"; \
1343         fi; \
1344         if test -n "$$REVISION"; then \
1345                 echo "#define REPO_VERSION \"-devel-$$REVISION\"" > versionstamp.h.tmp; \
1346 Index: src/mod_expire.c
1347 ===================================================================
1348 --- src/mod_expire.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
1349 +++ src/mod_expire.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
1350 @@ -342,7 +342,7 @@
1351                         buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
1352                         buffer_append_long(p->expire_tstmp, expires - srv->cur_ts); /* as expires >= srv->cur_ts the difference is >= 0 */
1353  
1354 -                       response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
1355 +                       response_header_insert(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
1356  
1357                         return HANDLER_GO_ON;
1358                 }
1359 Index: src/http_auth.c
1360 ===================================================================
1361 --- src/http_auth.c     (.../tags/lighttpd-1.4.23)      (revision 2620)
1362 +++ src/http_auth.c     (.../branches/lighttpd-1.4.x)   (revision 2620)
1363 @@ -918,15 +918,15 @@
1364         char a1[256];
1365         char a2[256];
1366  
1367 -       char *username;
1368 -       char *realm;
1369 -       char *nonce;
1370 -       char *uri;
1371 -       char *algorithm;
1372 -       char *qop;
1373 -       char *cnonce;
1374 -       char *nc;
1375 -       char *respons;
1376 +       char *username = NULL;
1377 +       char *realm = NULL;
1378 +       char *nonce = NULL;
1379 +       char *uri = NULL;
1380 +       char *algorithm = NULL;
1381 +       char *qop = NULL;
1382 +       char *cnonce = NULL;
1383 +       char *nc = NULL;
1384 +       char *respons = NULL;
1385  
1386         char *e, *c;
1387         const char *m = NULL;
1388 @@ -967,15 +967,9 @@
1389         dkv[6].ptr = &cnonce;
1390         dkv[7].ptr = &nc;
1391         dkv[8].ptr = &respons;
1392 -       dkv[9].ptr = NULL;
1393  
1394         UNUSED(req);
1395  
1396 -       for (i = 0; dkv[i].key; i++) {
1397 -               *(dkv[i].ptr) = NULL;
1398 -       }
1399 -
1400 -
1401         if (p->conf.auth_backend != AUTH_BACKEND_HTDIGEST &&
1402             p->conf.auth_backend != AUTH_BACKEND_PLAIN) {
1403                 log_error_write(srv, __FILE__, __LINE__, "s",
1404 Index: src/mod_redirect.c
1405 ===================================================================
1406 --- src/mod_redirect.c  (.../tags/lighttpd-1.4.23)      (revision 2620)
1407 +++ src/mod_redirect.c  (.../branches/lighttpd-1.4.x)   (revision 2620)
1408 @@ -203,7 +203,7 @@
1409                         }
1410                 } else {
1411                         const char **list;
1412 -                       size_t start, end;
1413 +                       size_t start;
1414                         size_t k;
1415  
1416                         /* it matched */
1417 @@ -213,17 +213,15 @@
1418  
1419                         buffer_reset(p->location);
1420  
1421 -                       start = 0; end = pattern_len;
1422 +                       start = 0;
1423                         for (k = 0; k < pattern_len; k++) {
1424                                 if (pattern[k] == '$' || pattern[k] == '%') {
1425                                         /* got one */
1426  
1427                                         size_t num = pattern[k + 1] - '0';
1428  
1429 -                                       end = k;
1430 +                                       buffer_append_string_len(p->location, pattern + start, k - start);
1431  
1432 -                                       buffer_append_string_len(p->location, pattern + start, end - start);
1433 -
1434                                         if (!isdigit((unsigned char)pattern[k + 1])) {
1435                                                 /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */
1436                                                 buffer_append_string_len(p->location, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2);
1437 Index: src/mod_webdav.c
1438 ===================================================================
1439 --- src/mod_webdav.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
1440 +++ src/mod_webdav.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
1441 @@ -1096,6 +1096,7 @@
1442  }
1443  #endif
1444  
1445 +#ifdef USE_LOCKS
1446  static int webdav_lockdiscovery(server *srv, connection *con,
1447                 buffer *locktoken, const char *lockscope, const char *locktype, int depth) {
1448  
1449 @@ -1150,6 +1151,8 @@
1450  
1451         return 0;
1452  }
1453 +#endif
1454 +
1455  /**
1456   * check if resource is having the right locks to access to resource
1457   *
1458 Index: src/configparser.y
1459 ===================================================================
1460 --- src/configparser.y  (.../tags/lighttpd-1.4.23)      (revision 2620)
1461 +++ src/configparser.y  (.../branches/lighttpd-1.4.x)   (revision 2620)
1462 @@ -72,7 +72,7 @@
1463        op1->free(op1);
1464        return (data_unset *)ds;
1465      } else {
1466 -      fprintf(stderr, "data type mismatch, cannot be merge\n");
1467 +      fprintf(stderr, "data type mismatch, cannot merge\n");
1468        return NULL;
1469      }
1470    }
1471 @@ -193,7 +193,6 @@
1472      du = configparser_merge_data(du, B);
1473      if (NULL == du) {
1474        ctx->ok = 0;
1475 -      du->free(du);
1476      }
1477      else {
1478        buffer_copy_string_buffer(du->key, A);
1479 @@ -470,7 +469,7 @@
1480      case CONFIG_COND_MATCH: {
1481  #ifdef HAVE_PCRE_H
1482        const char *errptr;
1483 -      int erroff;
1484 +      int erroff, captures;
1485  
1486        if (NULL == (dc->regex =
1487            pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) {
1488 @@ -487,6 +486,14 @@
1489          fprintf(stderr, "studying regex failed: %s -> %s\n",
1490              rvalue->ptr, errptr);
1491          ctx->ok = 0;
1492 +      } else if (0 != (pcre_fullinfo(dc->regex, dc->regex_study, PCRE_INFO_CAPTURECOUNT, &captures))) {
1493 +        fprintf(stderr, "getting capture count for regex failed: %s\n",
1494 +            rvalue->ptr);
1495 +        ctx->ok = 0;
1496 +      } else if (captures > 9) {
1497 +        fprintf(stderr, "Too many captures in regex, use (?:...) instead of (...): %s\n",
1498 +            rvalue->ptr);
1499 +        ctx->ok = 0;
1500        } else {
1501          dc->string = buffer_init_buffer(rvalue);
1502        }
1503 Index: src/mod_status.c
1504 ===================================================================
1505 --- src/mod_status.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
1506 +++ src/mod_status.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
1507 @@ -438,7 +438,7 @@
1508  
1509         buffer_append_string_len(b, CONST_STR_LEN(
1510                 "<hr />\n<pre><b>legend</b>\n"
1511 -               ". = connect, C = close, E = hard error\n"
1512 +               ". = connect, C = close, E = hard error, k = keep-alive\n"
1513                 "r = read, R = read-POST, W = write, h = handle-request\n"
1514                 "q = request-start,  Q = request-end\n"
1515                 "s = response-start, S = response-end\n"));
1516 @@ -449,8 +449,14 @@
1517  
1518         for (j = 0; j < srv->conns->used; j++) {
1519                 connection *c = srv->conns->ptr[j];
1520 -               const char *state = connection_get_short_state(c->state);
1521 +               const char *state;
1522  
1523 +               if (CON_STATE_READ == c->state && c->request.orig_uri->used > 0) {
1524 +                       state = "k";
1525 +               } else {
1526 +                       state = connection_get_short_state(c->state);
1527 +               }
1528 +
1529                 buffer_append_string_len(b, state, 1);
1530  
1531                 if (((j + 1) % 50) == 0) {
1532 @@ -497,7 +503,11 @@
1533  
1534                 buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">"));
1535  
1536 -               buffer_append_string(b, connection_get_state(c->state));
1537 +               if (CON_STATE_READ == c->state && c->request.orig_uri->used > 0) {
1538 +                       buffer_append_string_len(b, CONST_STR_LEN("keep-alive"));
1539 +               } else {
1540 +                       buffer_append_string(b, connection_get_state(c->state));
1541 +               }
1542  
1543                 buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">"));
1544  
1545 @@ -611,10 +621,10 @@
1546  }
1547  
1548  static handler_t mod_status_handle_server_statistics(server *srv, connection *con, void *p_d) {
1549 -       plugin_data *p = p_d;
1550 -       buffer *b = p->module_list;
1551 +       buffer *b;
1552         size_t i;
1553         array *st = srv->status;
1554 +       UNUSED(p_d);
1555  
1556         if (0 == st->used) {
1557                 /* we have nothing to send */
1558 Index: src/mod_ssi.c
1559 ===================================================================
1560 --- src/mod_ssi.c       (.../tags/lighttpd-1.4.23)      (revision 2620)
1561 +++ src/mod_ssi.c       (.../branches/lighttpd-1.4.x)   (revision 2620)
1562 @@ -362,7 +362,8 @@
1563         switch(ssicmd) {
1564         case SSI_ECHO: {
1565                 /* echo */
1566 -               int var = 0, enc = 0;
1567 +               int var = 0;
1568 +               /* int enc = 0; */
1569                 const char *var_val = NULL;
1570                 stat_cache_entry *sce = NULL;
1571  
1572 @@ -381,6 +382,7 @@
1573                         { NULL, SSI_ECHO_UNSET }
1574                 };
1575  
1576 +/*
1577                 struct {
1578                         const char *var;
1579                         enum { SSI_ENC_UNSET, SSI_ENC_URL, SSI_ENC_NONE, SSI_ENC_ENTITY } type;
1580 @@ -391,6 +393,7 @@
1581  
1582                         { NULL, SSI_ENC_UNSET }
1583                 };
1584 +*/
1585  
1586                 for (i = 2; i < n; i += 2) {
1587                         if (0 == strcmp(l[i], "var")) {
1588 @@ -405,6 +408,7 @@
1589                                         }
1590                                 }
1591                         } else if (0 == strcmp(l[i], "encoding")) {
1592 +/*
1593                                 int j;
1594  
1595                                 for (j = 0; encvars[j].var; j++) {
1596 @@ -413,6 +417,7 @@
1597                                                 break;
1598                                         }
1599                                 }
1600 +*/
1601                         } else {
1602                                 log_error_write(srv, __FILE__, __LINE__, "sss",
1603                                                 "ssi: unknow attribute for ",
1604 Index: src/mod_auth.c
1605 ===================================================================
1606 --- src/mod_auth.c      (.../tags/lighttpd-1.4.23)      (revision 2620)
1607 +++ src/mod_auth.c      (.../branches/lighttpd-1.4.x)   (revision 2620)
1608 @@ -468,7 +468,7 @@
1609  
1610                         if (method == NULL) {
1611                                 log_error_write(srv, __FILE__, __LINE__, "ss",
1612 -                                               "the require field is missing in:",
1613 +                                               "the method field is missing in:",
1614                                                 "auth.require = ( \"...\" => ( ..., \"method\" => \"...\" ) )");
1615                                 return HANDLER_ERROR;
1616                         } else {
1617 @@ -483,7 +483,7 @@
1618  
1619                         if (realm == NULL) {
1620                                 log_error_write(srv, __FILE__, __LINE__, "ss",
1621 -                                               "the require field is missing in:",
1622 +                                               "the realm field is missing in:",
1623                                                 "auth.require = ( \"...\" => ( ..., \"realm\" => \"...\" ) )");
1624                                 return HANDLER_ERROR;
1625                         }
1626 Index: src/mod_cml_lua.c
1627 ===================================================================
1628 --- src/mod_cml_lua.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
1629 +++ src/mod_cml_lua.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
1630 @@ -2,6 +2,7 @@
1631  #include <stdio.h>
1632  #include <errno.h>
1633  #include <time.h>
1634 +#include <string.h>
1635  
1636  #include "mod_cml.h"
1637  #include "mod_cml_funcs.h"
1638 Index: src/http-header-glue.c
1639 ===================================================================
1640 --- src/http-header-glue.c      (.../tags/lighttpd-1.4.23)      (revision 2620)
1641 +++ src/http-header-glue.c      (.../branches/lighttpd-1.4.x)   (revision 2620)
1642 @@ -259,7 +259,7 @@
1643                                         }
1644  
1645                                         if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) {
1646 -                                               con->http_status = 304;
1647 +                                               if ('\0' == mtime->ptr[used_len]) con->http_status = 304;
1648                                                 return HANDLER_FINISHED;
1649                                         } else {
1650                                                 char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
1651 @@ -281,15 +281,16 @@
1652                                                 strncpy(buf, con->request.http_if_modified_since, used_len);
1653                                                 buf[used_len] = '\0';
1654  
1655 -                                               tm.tm_isdst = 0;
1656                                                 if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
1657                                                         con->http_status = 412;
1658                                                         con->mode = DIRECT;
1659                                                         return HANDLER_FINISHED;
1660                                                 }
1661 +                                               tm.tm_isdst = 0;
1662                                                 t_header = mktime(&tm);
1663  
1664                                                 strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
1665 +                                               tm.tm_isdst = 0;
1666                                                 t_file = mktime(&tm);
1667  
1668                                                 if (t_file > t_header) return HANDLER_GO_ON;
1669 @@ -318,7 +319,7 @@
1670                 }
1671  
1672                 if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) {
1673 -                       con->http_status = 304;
1674 +                       if ('\0' == mtime->ptr[used_len]) con->http_status = 304;
1675                         return HANDLER_FINISHED;
1676                 } else {
1677                         char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
1678 @@ -331,18 +332,17 @@
1679                         strncpy(buf, con->request.http_if_modified_since, used_len);
1680                         buf[used_len] = '\0';
1681  
1682 -                       tm.tm_isdst = 0;
1683                         if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
1684                                 /**
1685                                  * parsing failed, let's get out of here 
1686                                  */
1687 -                               log_error_write(srv, __FILE__, __LINE__, "ss",
1688 -                                               "strptime() failed on", buf);
1689                                 return HANDLER_GO_ON;
1690                         }
1691 +                       tm.tm_isdst = 0;
1692                         t_header = mktime(&tm);
1693  
1694                         strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
1695 +                       tm.tm_isdst = 0;
1696                         t_file = mktime(&tm);
1697  
1698                         if (t_file > t_header) return HANDLER_GO_ON;
1699 Index: src/mod_setenv.c
1700 ===================================================================
1701 --- src/mod_setenv.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
1702 +++ src/mod_setenv.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
1703 @@ -215,7 +215,7 @@
1704         return HANDLER_GO_ON;
1705  }
1706  
1707 -REQUESTDONE_FUNC(mod_setenv_reset) {
1708 +CONNECTION_FUNC(mod_setenv_reset) {
1709         plugin_data *p = p_d;
1710  
1711         UNUSED(srv);
1712 @@ -240,7 +240,7 @@
1713         p->set_defaults  = mod_setenv_set_defaults;
1714         p->cleanup     = mod_setenv_free;
1715  
1716 -       p->handle_request_done  = mod_setenv_reset;
1717 +       p->connection_reset  = mod_setenv_reset;
1718  
1719         p->data        = NULL;
1720  
1721 Index: src/mod_fastcgi.c
1722 ===================================================================
1723 --- src/mod_fastcgi.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
1724 +++ src/mod_fastcgi.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
1725 @@ -122,24 +122,11 @@
1726          *
1727          */
1728  
1729 -       unsigned short min_procs;
1730         unsigned short max_procs;
1731         size_t num_procs;    /* how many procs are started */
1732         size_t active_procs; /* how many of them are really running */
1733  
1734 -       unsigned short max_load_per_proc;
1735 -
1736         /*
1737 -        * kick the process from the list if it was not
1738 -        * used for idle_timeout until min_procs is
1739 -        * reached. this helps to get the processlist
1740 -        * small again we had a small peak load.
1741 -        *
1742 -        */
1743 -
1744 -       unsigned short idle_timeout;
1745 -
1746 -       /*
1747          * time after a disabled remote connection is tried to be re-enabled
1748          *
1749          *
1750 @@ -384,6 +371,21 @@
1751  /* ok, we need a prototype */
1752  static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents);
1753  
1754 +static void reset_signals(void) {
1755 +#ifdef SIGTTOU
1756 +       signal(SIGTTOU, SIG_DFL);
1757 +#endif
1758 +#ifdef SIGTTIN
1759 +       signal(SIGTTIN, SIG_DFL);
1760 +#endif
1761 +#ifdef SIGTSTP
1762 +       signal(SIGTSTP, SIG_DFL);
1763 +#endif
1764 +       signal(SIGHUP, SIG_DFL);
1765 +       signal(SIGPIPE, SIG_DFL);
1766 +       signal(SIGUSR1, SIG_DFL);
1767 +}
1768 +
1769  static void fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) {
1770         buffer_copy_string_len(b, CONST_STR_LEN("fastcgi.backend."));
1771         buffer_append_string_buffer(b, host->id);
1772 @@ -993,8 +995,6 @@
1773                                 close(fcgi_fd);
1774                         }
1775  
1776 -                       openDevNull(STDERR_FILENO);
1777 -
1778                         /* we don't need the client socket */
1779                         for (i = 3; i < 256; i++) {
1780                                 close(i);
1781 @@ -1054,6 +1054,7 @@
1782                                 *c = '/';
1783                         }
1784  
1785 +                       reset_signals();
1786  
1787                         /* exec the cgi */
1788                         execve(arg.ptr[0], arg.ptr, env.ptr);
1789 @@ -1235,20 +1236,17 @@
1790  
1791                                                 { "check-local",       NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },      /* 5 */
1792                                                 { "port",              NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 6 */
1793 -                                               { "min-procs-not-working",         NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 7 this is broken for now */
1794 -                                               { "max-procs",         NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 8 */
1795 -                                               { "max-load-per-proc", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 9 */
1796 -                                               { "idle-timeout",      NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 10 */
1797 -                                               { "disable-time",      NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 11 */
1798 +                                               { "max-procs",         NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 7 */
1799 +                                               { "disable-time",      NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },        /* 8 */
1800  
1801 -                                               { "bin-environment",   NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },        /* 12 */
1802 -                                               { "bin-copy-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },     /* 13 */
1803 +                                               { "bin-environment",   NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },        /* 9 */
1804 +                                               { "bin-copy-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },     /* 10 */
1805  
1806 -                                               { "broken-scriptfilename", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },  /* 14 */
1807 -                                               { "allow-x-send-file",  NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },      /* 15 */
1808 -                                               { "strip-request-uri",  NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },      /* 16 */
1809 -                                               { "kill-signal",        NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },      /* 17 */
1810 -                                               { "fix-root-scriptname",   NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },  /* 18 */
1811 +                                               { "broken-scriptfilename", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },  /* 11 */
1812 +                                               { "allow-x-send-file",  NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },     /* 12 */
1813 +                                               { "strip-request-uri",  NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },      /* 13 */
1814 +                                               { "kill-signal",        NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },       /* 14 */
1815 +                                               { "fix-root-scriptname",   NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },  /* 15 */
1816  
1817                                                 { NULL,                NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
1818                                         };
1819 @@ -1267,12 +1265,9 @@
1820                                         buffer_copy_string_buffer(host->id, da_host->key);
1821  
1822                                         host->check_local  = 1;
1823 -                                       host->min_procs    = 4;
1824                                         host->max_procs    = 4;
1825 -                                       host->max_load_per_proc = 1;
1826 -                                       host->idle_timeout = 60;
1827                                         host->mode = FCGI_RESPONDER;
1828 -                                       host->disable_time = 60;
1829 +                                       host->disable_time = 1;
1830                                         host->break_scriptfilename_for_php = 0;
1831                                         host->allow_xsendfile = 0; /* handle X-LIGHTTPD-send-file */
1832                                         host->kill_signal = SIGTERM;
1833 @@ -1286,19 +1281,16 @@
1834  
1835                                         fcv[5].destination = &(host->check_local);
1836                                         fcv[6].destination = &(host->port);
1837 -                                       fcv[7].destination = &(host->min_procs);
1838 -                                       fcv[8].destination = &(host->max_procs);
1839 -                                       fcv[9].destination = &(host->max_load_per_proc);
1840 -                                       fcv[10].destination = &(host->idle_timeout);
1841 -                                       fcv[11].destination = &(host->disable_time);
1842 +                                       fcv[7].destination = &(host->max_procs);
1843 +                                       fcv[8].destination = &(host->disable_time);
1844  
1845 -                                       fcv[12].destination = host->bin_env;
1846 -                                       fcv[13].destination = host->bin_env_copy;
1847 -                                       fcv[14].destination = &(host->break_scriptfilename_for_php);
1848 -                                       fcv[15].destination = &(host->allow_xsendfile);
1849 -                                       fcv[16].destination = host->strip_request_uri;
1850 -                                       fcv[17].destination = &(host->kill_signal);
1851 -                                       fcv[18].destination = &(host->fix_root_path_name);
1852 +                                       fcv[9].destination = host->bin_env;
1853 +                                       fcv[10].destination = host->bin_env_copy;
1854 +                                       fcv[11].destination = &(host->break_scriptfilename_for_php);
1855 +                                       fcv[12].destination = &(host->allow_xsendfile);
1856 +                                       fcv[13].destination = host->strip_request_uri;
1857 +                                       fcv[14].destination = &(host->kill_signal);
1858 +                                       fcv[15].destination = &(host->fix_root_path_name);
1859  
1860                                         if (0 != config_insert_values_internal(srv, da_host->value, fcv)) {
1861                                                 return HANDLER_ERROR;
1862 @@ -1355,23 +1347,16 @@
1863                                                 /* a local socket + self spawning */
1864                                                 size_t pno;
1865  
1866 -                                               /* HACK:  just to make sure the adaptive spawing is disabled */
1867 -                                               host->min_procs = host->max_procs;
1868 -
1869 -                                               if (host->min_procs > host->max_procs) host->max_procs = host->min_procs;
1870 -                                               if (host->max_load_per_proc < 1) host->max_load_per_proc = 0;
1871 -
1872                                                 if (s->debug) {
1873 -                                                       log_error_write(srv, __FILE__, __LINE__, "ssbsdsbsdsd",
1874 +                                                       log_error_write(srv, __FILE__, __LINE__, "ssbsdsbsd",
1875                                                                         "--- fastcgi spawning local",
1876                                                                         "\n\tproc:", host->bin_path,
1877                                                                         "\n\tport:", host->port,
1878                                                                         "\n\tsocket", host->unixsocket,
1879 -                                                                       "\n\tmin-procs:", host->min_procs,
1880                                                                         "\n\tmax-procs:", host->max_procs);
1881                                                 }
1882  
1883 -                                               for (pno = 0; pno < host->min_procs; pno++) {
1884 +                                               for (pno = 0; pno < host->max_procs; pno++) {
1885                                                         fcgi_proc *proc;
1886  
1887                                                         proc = fastcgi_process_init();
1888 @@ -1391,7 +1376,7 @@
1889                                                                                 "--- fastcgi spawning",
1890                                                                                 "\n\tport:", host->port,
1891                                                                                 "\n\tsocket", host->unixsocket,
1892 -                                                                               "\n\tcurrent:", pno, "/", host->min_procs);
1893 +                                                                               "\n\tcurrent:", pno, "/", host->max_procs);
1894                                                         }
1895  
1896                                                         if (fcgi_spawn_connection(srv, p, host, proc)) {
1897 @@ -1426,7 +1411,6 @@
1898  
1899                                                 host->first = proc;
1900  
1901 -                                               host->min_procs = 1;
1902                                                 host->max_procs = 1;
1903                                         }
1904  
1905 @@ -2739,7 +2723,7 @@
1906                                         log_error_write(srv, __FILE__, __LINE__, "ssbsdsd",
1907                                                         "--- fastcgi spawning",
1908                                                         "\n\tsocket", proc->connection_name,
1909 -                                                       "\n\tcurrent:", 1, "/", host->min_procs);
1910 +                                                       "\n\tcurrent:", 1, "/", host->max_procs);
1911                                 }
1912  
1913                                 if (fcgi_spawn_connection(srv, p, host, proc)) {
1914 @@ -2778,8 +2762,11 @@
1915          *     - tcp socket (do not check host->host->uses, as it may be not set which means INADDR_LOOPBACK)
1916          *     - unix socket
1917          */
1918 -       if (!host ||
1919 -           (!host->port && !host->unixsocket->used)) {
1920 +       if (!host) {
1921 +               log_error_write(srv, __FILE__, __LINE__, "s", "fatal error: host = NULL");
1922 +               return HANDLER_ERROR;
1923 +       }
1924 +       if ((!host->port && !host->unixsocket->used)) {
1925                 log_error_write(srv, __FILE__, __LINE__, "sxddd",
1926                                 "write-req: error",
1927                                 host,
1928 @@ -2787,7 +2774,7 @@
1929                                 host->port,
1930                                 host->unixsocket->used);
1931  
1932 -               hctx->proc->disabled_until = srv->cur_ts + 10;
1933 +               hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1934                 hctx->proc->state = PROC_STATE_DIED;
1935  
1936                 return HANDLER_ERROR;
1937 @@ -2803,7 +2790,7 @@
1938                         log_error_write(srv, __FILE__, __LINE__, "ss",
1939                                         "getsockopt failed:", strerror(errno));
1940  
1941 -                       hctx->proc->disabled_until = srv->cur_ts + 10;
1942 +                       hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1943                         hctx->proc->state = PROC_STATE_DIED;
1944  
1945                         return HANDLER_ERROR;
1946 @@ -2817,7 +2804,7 @@
1947                                                 "socket:", hctx->proc->connection_name);
1948                         }
1949  
1950 -                       hctx->proc->disabled_until = srv->cur_ts + 5;
1951 +                       hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1952  
1953                         if (hctx->proc->is_local) {
1954                                 hctx->proc->state = PROC_STATE_DIED_WAIT_FOR_PID;
1955 @@ -2910,13 +2897,13 @@
1956                         /* cool down the backend, it is overloaded
1957                          * -> EAGAIN */
1958  
1959 -                       log_error_write(srv, __FILE__, __LINE__, "ssdsd",
1960 -                               "backend is overloaded; we'll disable it for 2 seconds and send the request to another backend instead:",
1961 +                       log_error_write(srv, __FILE__, __LINE__, "sdssdsd",
1962 +                               "backend is overloaded; we'll disable it for", hctx->host->disable_time, "seconds and send the request to another backend instead:",
1963                                 "reconnects:", hctx->reconnects,
1964                                 "load:", host->load);
1965  
1966  
1967 -                       hctx->proc->disabled_until = srv->cur_ts + 2;
1968 +                       hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1969                         hctx->proc->state = PROC_STATE_OVERLOADED;
1970  
1971                         fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc);
1972 @@ -2930,18 +2917,18 @@
1973                          * - ECONNREFUSED for tcp-ip sockets
1974                          * - ENOENT for unix-domain-sockets
1975                          *
1976 -                        * for check if the host is back in 5 seconds
1977 +                        * for check if the host is back in hctx->host->disable_time seconds
1978                          *  */
1979  
1980 -                       hctx->proc->disabled_until = srv->cur_ts + 5;
1981 +                       hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1982                         if (hctx->proc->is_local) {
1983                                 hctx->proc->state = PROC_STATE_DIED_WAIT_FOR_PID;
1984                         } else {
1985                                 hctx->proc->state = PROC_STATE_DIED;
1986                         }
1987  
1988 -                       log_error_write(srv, __FILE__, __LINE__, "ssdsd",
1989 -                               "backend died; we'll disable it for 5 seconds and send the request to another backend instead:",
1990 +                       log_error_write(srv, __FILE__, __LINE__, "sdssdsd",
1991 +                               "backend died; we'll disable it for", hctx->host->disable_time, "seconds and send the request to another backend instead:",
1992                                 "reconnects:", hctx->reconnects,
1993                                 "load:", host->load);
1994  
1995 @@ -3032,11 +3019,6 @@
1996                                                 "reconnect attempts:", hctx->reconnects);
1997  
1998                                 return HANDLER_ERROR;
1999 -                       case EAGAIN:
2000 -                       case EINTR:
2001 -                               fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
2002 -
2003 -                               return HANDLER_WAIT_FOR_EVENT;
2004                         default:
2005                                 log_error_write(srv, __FILE__, __LINE__, "ssd",
2006                                                 "write failed:", strerror(errno), errno);
2007 @@ -3266,7 +3248,7 @@
2008                                                 log_error_write(srv, __FILE__, __LINE__, "ssbsdsd",
2009                                                                 "--- fastcgi spawning",
2010                                                                 "\n\tsocket", proc->connection_name,
2011 -                                                               "\n\tcurrent:", 1, "/", host->min_procs);
2012 +                                                               "\n\tcurrent:", 1, "/", host->max_procs);
2013                                         }
2014  
2015                                         if (fcgi_spawn_connection(srv, p, host, proc)) {
2016 @@ -3288,18 +3270,18 @@
2017                                     hctx->reconnects < 5) {
2018                                         fcgi_reconnect(srv, hctx);
2019  
2020 -                                       log_error_write(srv, __FILE__, __LINE__, "ssbsbs",
2021 +                                       log_error_write(srv, __FILE__, __LINE__, "ssbsBSBs",
2022                                                 "response not received, request not sent",
2023                                                 "on socket:", proc->connection_name,
2024 -                                               "for", con->uri.path, ", reconnecting");
2025 +                                               "for", con->uri.path, "?", con->uri.query, ", reconnecting");
2026  
2027                                         return HANDLER_WAIT_FOR_FD;
2028                                 }
2029  
2030 -                               log_error_write(srv, __FILE__, __LINE__, "sosbsbs",
2031 +                               log_error_write(srv, __FILE__, __LINE__, "sosbsBSBs",
2032                                                 "response not received, request sent:", hctx->wb->bytes_out,
2033                                                 "on socket:", proc->connection_name,
2034 -                                               "for", con->uri.path, ", closing connection");
2035 +                                               "for", con->uri.path, "?", con->uri.query, ", closing connection");
2036  
2037                                 fcgi_connection_close(srv, hctx);
2038  
2039 @@ -3311,10 +3293,10 @@
2040                                 /* response might have been already started, kill the connection */
2041                                 fcgi_connection_close(srv, hctx);
2042  
2043 -                               log_error_write(srv, __FILE__, __LINE__, "ssbsbs",
2044 +                               log_error_write(srv, __FILE__, __LINE__, "ssbsBSBs",
2045                                                 "response already sent out, but backend returned error",
2046                                                 "on socket:", proc->connection_name,
2047 -                                               "for", con->uri.path, ", terminating connection");
2048 +                                               "for", con->uri.path, "?", con->uri.query, ", terminating connection");
2049  
2050                                 connection_set_state(srv, con, CON_STATE_ERROR);
2051                         }
2052 @@ -3364,9 +3346,9 @@
2053                          * even if the FCGI_FIN packet is not received yet
2054                          */
2055                 } else {
2056 -                       log_error_write(srv, __FILE__, __LINE__, "sbsbsd",
2057 +                       log_error_write(srv, __FILE__, __LINE__, "sBSbsbsd",
2058                                         "error: unexpected close of fastcgi connection for",
2059 -                                       con->uri.path,
2060 +                                       con->uri.path, "?", con->uri.query,
2061                                         "(no fastcgi process on socket:", proc->connection_name, "?)",
2062                                         hctx->state);
2063  
2064 @@ -3489,25 +3471,27 @@
2065                 /* check if extension matches */
2066                 for (k = 0; k < p->conf.exts->used; k++) {
2067                         size_t ct_len; /* length of the config entry */
2068 +                       fcgi_extension *ext = p->conf.exts->exts[k];
2069  
2070 -                       extension = p->conf.exts->exts[k];
2071 +                       if (ext->key->used == 0) continue;
2072  
2073 -                       if (extension->key->used == 0) continue;
2074 +                       ct_len = ext->key->used - 1;
2075  
2076 -                       ct_len = extension->key->used - 1;
2077 -
2078                         /* check _url_ in the form "/fcgi_pattern" */
2079 -                       if (extension->key->ptr[0] == '/') {
2080 +                       if (ext->key->ptr[0] == '/') {
2081                                 if ((ct_len <= con->uri.path->used -1) &&
2082 -                                   (strncmp(con->uri.path->ptr, extension->key->ptr, ct_len) == 0))
2083 +                                   (strncmp(con->uri.path->ptr, ext->key->ptr, ct_len) == 0)) {
2084 +                                       extension = ext;
2085                                         break;
2086 -                       } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len))) {
2087 +                               }
2088 +                       } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, ext->key->ptr, ct_len))) {
2089                                 /* check extension in the form ".fcg" */
2090 +                               extension = ext;
2091                                 break;
2092                         }
2093                 }
2094                 /* extension doesn't match */
2095 -               if (k == p->conf.exts->used) {
2096 +               if (NULL == extension) {
2097                         return HANDLER_GO_ON;
2098                 }
2099         }
2100 @@ -3535,8 +3519,8 @@
2101                 if (!extension->note_is_sent) {
2102                         extension->note_is_sent = 1;
2103  
2104 -                       log_error_write(srv, __FILE__, __LINE__, "sbsbs",
2105 -                                       "all handlers for ", con->uri.path,
2106 +                       log_error_write(srv, __FILE__, __LINE__, "sBSbsbs",
2107 +                                       "all handlers for", con->uri.path, "?", con->uri.query,
2108                                         "on", extension->key,
2109                                         "are down.");
2110                 }
2111 @@ -3727,107 +3711,12 @@
2112                         for (n = 0; n < ex->used; n++) {
2113  
2114                                 fcgi_proc *proc;
2115 -                               unsigned long sum_load = 0;
2116                                 fcgi_extension_host *host;
2117  
2118                                 host = ex->hosts[n];
2119  
2120                                 fcgi_restart_dead_procs(srv, p, host);
2121  
2122 -                               for (proc = host->first; proc; proc = proc->next) {
2123 -                                       sum_load += proc->load;
2124 -                               }
2125 -
2126 -                               if (host->num_procs &&
2127 -                                   host->num_procs < host->max_procs &&
2128 -                                   (sum_load / host->num_procs) > host->max_load_per_proc) {
2129 -                                       /* overload, spawn new child */
2130 -                                       if (p->conf.debug) {
2131 -                                               log_error_write(srv, __FILE__, __LINE__, "s",
2132 -                                                               "overload detected, spawning a new child");
2133 -                                       }
2134 -
2135 -                                       for (proc = host->unused_procs; proc && proc->pid != 0; proc = proc->next);
2136 -
2137 -                                       if (proc) {
2138 -                                               if (proc == host->unused_procs) host->unused_procs = proc->next;
2139 -
2140 -                                               if (proc->next) proc->next->prev = NULL;
2141 -
2142 -                                               host->max_id++;
2143 -                                       } else {
2144 -                                               proc = fastcgi_process_init();
2145 -                                               proc->id = host->max_id++;
2146 -                                       }
2147 -
2148 -                                       host->num_procs++;
2149 -
2150 -                                       if (buffer_is_empty(host->unixsocket)) {
2151 -                                               proc->port = host->port + proc->id;
2152 -                                       } else {
2153 -                                               buffer_copy_string_buffer(proc->unixsocket, host->unixsocket);
2154 -                                               buffer_append_string_len(proc->unixsocket, CONST_STR_LEN("-"));
2155 -                                               buffer_append_long(proc->unixsocket, proc->id);
2156 -                                       }
2157 -
2158 -                                       if (fcgi_spawn_connection(srv, p, host, proc)) {
2159 -                                               log_error_write(srv, __FILE__, __LINE__, "s",
2160 -                                                               "ERROR: spawning fcgi failed.");
2161 -                                               return HANDLER_ERROR;
2162 -                                       }
2163 -
2164 -                                       proc->prev = NULL;
2165 -                                       proc->next = host->first;
2166 -                                       if (host->first) {
2167 -                                               host->first->prev = proc;
2168 -                                       }
2169 -                                       host->first = proc;
2170 -                               }
2171 -
2172 -                               for (proc = host->first; proc; proc = proc->next) {
2173 -                                       if (proc->load != 0) break;
2174 -                                       if (host->num_procs <= host->min_procs) break;
2175 -                                       if (proc->pid == 0) continue;
2176 -
2177 -                                       if (srv->cur_ts - proc->last_used > host->idle_timeout) {
2178 -                                               /* a proc is idling for a long time now,
2179 -                                                * terminate it */
2180 -
2181 -                                               if (p->conf.debug) {
2182 -                                                       log_error_write(srv, __FILE__, __LINE__, "ssbsd",
2183 -                                                                       "idle-timeout reached; terminating child:",
2184 -                                                                       "socket:", proc->connection_name,
2185 -                                                                       "pid", proc->pid);
2186 -                                               }
2187 -
2188 -
2189 -                                               if (proc->next) proc->next->prev = proc->prev;
2190 -                                               if (proc->prev) proc->prev->next = proc->next;
2191 -
2192 -                                               if (proc->prev == NULL) host->first = proc->next;
2193 -
2194 -                                               proc->prev = NULL;
2195 -                                               proc->next = host->unused_procs;
2196 -
2197 -                                               if (host->unused_procs) host->unused_procs->prev = proc;
2198 -                                               host->unused_procs = proc;
2199 -
2200 -                                               kill(proc->pid, SIGTERM);
2201 -
2202 -                                               proc->state = PROC_STATE_KILLED;
2203 -
2204 -                                               log_error_write(srv, __FILE__, __LINE__, "ssbsd",
2205 -                                                                       "killed:",
2206 -                                                                       "socket:", proc->connection_name,
2207 -                                                                       "pid", proc->pid);
2208 -
2209 -                                               host->num_procs--;
2210 -
2211 -                                               /* proc is now in unused, let the next second handle the next process */
2212 -                                               break;
2213 -                                       }
2214 -                               }
2215 -
2216                                 for (proc = host->unused_procs; proc; proc = proc->next) {
2217                                         int status;
2218  
2219 Index: src/fdevent_poll.c
2220 ===================================================================
2221 --- src/fdevent_poll.c  (.../tags/lighttpd-1.4.23)      (revision 2620)
2222 +++ src/fdevent_poll.c  (.../branches/lighttpd-1.4.x)   (revision 2620)
2223 @@ -132,7 +132,7 @@
2224         if (poll_r & POLLNVAL) r |= FDEVENT_NVAL;
2225         if (poll_r & POLLPRI) r |= FDEVENT_PRI;
2226  
2227 -       return ev->pollfds[ndx].revents;
2228 +       return r;
2229  }
2230  
2231  static int fdevent_poll_event_get_fd(fdevents *ev, size_t ndx) {
2232 Index: src/fdevent_select.c
2233 ===================================================================
2234 --- src/fdevent_select.c        (.../tags/lighttpd-1.4.23)      (revision 2620)
2235 +++ src/fdevent_select.c        (.../branches/lighttpd-1.4.x)   (revision 2620)
2236 @@ -38,7 +38,7 @@
2237         UNUSED(fde_ndx);
2238  
2239         /* we should be protected by max-fds, but you never know */
2240 -       assert(fd < FD_SETSIZE);
2241 +       assert(fd < ((int)FD_SETSIZE));
2242  
2243         if (events & FDEVENT_IN) {
2244                 FD_SET(fd, &(ev->select_set_read));
2245 Index: src/CMakeLists.txt
2246 ===================================================================
2247 Index: src/server.c
2248 ===================================================================
2249 --- src/server.c        (.../tags/lighttpd-1.4.23)      (revision 2620)
2250 +++ src/server.c        (.../branches/lighttpd-1.4.x)   (revision 2620)
2251 @@ -187,6 +187,7 @@
2252         CLEAN(cond_check_buf);
2253  
2254         CLEAN(srvconf.errorlog_file);
2255 +       CLEAN(srvconf.breakagelog_file);
2256         CLEAN(srvconf.groupname);
2257         CLEAN(srvconf.username);
2258         CLEAN(srvconf.changeroot);
2259 @@ -242,8 +243,8 @@
2260         srv->srvconf.reject_expect_100_with_417 = 1;
2261  
2262         /* use syslog */
2263 -       srv->errorlog_fd = -1;
2264 -       srv->errorlog_mode = ERRORLOG_STDERR;
2265 +       srv->errorlog_fd = STDERR_FILENO;
2266 +       srv->errorlog_mode = ERRORLOG_FD;
2267  
2268         srv->split_vals = array_init();
2269  
2270 @@ -271,6 +272,7 @@
2271         CLEAN(cond_check_buf);
2272  
2273         CLEAN(srvconf.errorlog_file);
2274 +       CLEAN(srvconf.breakagelog_file);
2275         CLEAN(srvconf.groupname);
2276         CLEAN(srvconf.username);
2277         CLEAN(srvconf.changeroot);
2278 @@ -717,7 +719,7 @@
2279                 }
2280  
2281                 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2282 -                       srv->max_fds = rlim.rlim_cur < FD_SETSIZE - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2283 +                       srv->max_fds = rlim.rlim_cur < ((int)FD_SETSIZE) - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2284                 } else {
2285                         srv->max_fds = rlim.rlim_cur;
2286                 }
2287 @@ -730,7 +732,7 @@
2288  #endif
2289                 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2290                         /* don't raise the limit above FD_SET_SIZE */
2291 -                       if (srv->max_fds > FD_SETSIZE - 200) {
2292 +                       if (srv->max_fds > ((int)FD_SETSIZE) - 200) {
2293                                 log_error_write(srv, __FILE__, __LINE__, "sd",
2294                                                 "can't raise max filedescriptors above",  FD_SETSIZE - 200,
2295                                                 "if event-handler is 'select'. Use 'poll' or something else or reduce server.max-fds.");
2296 @@ -780,7 +782,7 @@
2297                  * Change group before chroot, when we have access
2298                  * to /etc/group
2299                  * */
2300 -               if (srv->srvconf.groupname->used) {
2301 +               if (NULL != grp) {
2302                         setgid(grp->gr_gid);
2303                         setgroups(0, NULL);
2304                         if (srv->srvconf.username->used) {
2305 @@ -804,7 +806,7 @@
2306  #endif
2307  #ifdef HAVE_PWD_H
2308                 /* drop root privs */
2309 -               if (srv->srvconf.username->used) {
2310 +               if (NULL != pwd) {
2311                         setuid(pwd->pw_uid);
2312                 }
2313  #endif
2314 @@ -843,7 +845,7 @@
2315                 }
2316  
2317                 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2318 -                       srv->max_fds = rlim.rlim_cur < FD_SETSIZE - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2319 +                       srv->max_fds = rlim.rlim_cur < ((int)FD_SETSIZE) - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2320                 } else {
2321                         srv->max_fds = rlim.rlim_cur;
2322                 }
2323 @@ -857,7 +859,7 @@
2324  #endif
2325                 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2326                         /* don't raise the limit above FD_SET_SIZE */
2327 -                       if (srv->max_fds > FD_SETSIZE - 200) {
2328 +                       if (srv->max_fds > ((int)FD_SETSIZE) - 200) {
2329                                 log_error_write(srv, __FILE__, __LINE__, "sd",
2330                                                 "can't raise max filedescriptors above",  FD_SETSIZE - 200,
2331                                                 "if event-handler is 'select'. Use 'poll' or something else or reduce server.max-fds.");
2332 Index: src/mod_dirlisting.c
2333 ===================================================================
2334 --- src/mod_dirlisting.c        (.../tags/lighttpd-1.4.23)      (revision 2620)
2335 +++ src/mod_dirlisting.c        (.../branches/lighttpd-1.4.x)   (revision 2620)
2336 @@ -198,7 +198,7 @@
2337         data_unset *du;
2338  
2339         if (NULL != (du = array_get_element(ca, option))) {
2340 -               data_array *da = (data_array *)du;
2341 +               data_array *da;
2342                 size_t j;
2343  
2344                 if (du->type != TYPE_ARRAY) {
2345 Index: src/mod_magnet.c
2346 ===================================================================
2347 --- src/mod_magnet.c    (.../tags/lighttpd-1.4.23)      (revision 2620)
2348 +++ src/mod_magnet.c    (.../branches/lighttpd-1.4.x)   (revision 2620)
2349 @@ -283,17 +283,11 @@
2350  }
2351  
2352  static int magnet_reqhdr_get(lua_State *L) {
2353 -       server *srv;
2354         connection *con;
2355         data_string *ds;
2356  
2357         const char *key = luaL_checkstring(L, 2);
2358  
2359 -       lua_pushstring(L, "lighty.srv");
2360 -       lua_gettable(L, LUA_REGISTRYINDEX);
2361 -       srv = lua_touserdata(L, -1);
2362 -       lua_pop(L, 1);
2363 -
2364         lua_pushstring(L, "lighty.con");
2365         lua_gettable(L, LUA_REGISTRYINDEX);
2366         con = lua_touserdata(L, -1);
2367 Index: src/log.c
2368 ===================================================================
2369 --- src/log.c   (.../tags/lighttpd-1.4.23)      (revision 2620)
2370 +++ src/log.c   (.../branches/lighttpd-1.4.x)   (revision 2620)
2371 @@ -62,7 +62,6 @@
2372                 /* create write pipe and spawn process */
2373  
2374                 int to_log_fds[2];
2375 -               pid_t pid;
2376  
2377                 if (pipe(to_log_fds)) {
2378                         log_error_write(srv, __FILE__, __LINE__, "ss", "pipe failed: ", strerror(errno));
2379 @@ -70,7 +69,7 @@
2380                 }
2381  
2382                 /* fork, execve */
2383 -               switch (pid = fork()) {
2384 +               switch (fork()) {
2385                 case 0:
2386                         /* child */
2387                         close(STDIN_FILENO);
2388 @@ -150,14 +149,14 @@
2389   */
2390  
2391  int log_error_open(server *srv) {
2392 -       int close_stderr = 1;
2393 -
2394  #ifdef HAVE_SYSLOG_H
2395         /* perhaps someone wants to use syslog() */
2396         openlog("lighttpd", LOG_CONS | LOG_PID, LOG_DAEMON);
2397  #endif
2398 -       srv->errorlog_mode = ERRORLOG_STDERR;
2399  
2400 +       srv->errorlog_mode = ERRORLOG_FD;
2401 +       srv->errorlog_fd = STDERR_FILENO;
2402 +
2403         if (srv->srvconf.errorlog_use_syslog) {
2404                 srv->errorlog_mode = ERRORLOG_SYSLOG;
2405         } else if (!buffer_is_empty(srv->srvconf.errorlog_file)) {
2406 @@ -171,20 +170,36 @@
2407  
2408         log_error_write(srv, __FILE__, __LINE__, "s", "server started");
2409  
2410 -#ifdef HAVE_VALGRIND_VALGRIND_H
2411 -       /* don't close stderr for debugging purposes if run in valgrind */
2412 -       if (RUNNING_ON_VALGRIND) close_stderr = 0;
2413 -#endif
2414 -
2415 -       if (srv->errorlog_mode == ERRORLOG_STDERR && srv->srvconf.dont_daemonize) {
2416 +       if (srv->errorlog_mode == ERRORLOG_FD && !srv->srvconf.dont_daemonize) {
2417                 /* We can only log to stderr in dont-daemonize mode;
2418                  * if we do daemonize and no errorlog file is specified, we log into /dev/null
2419                  */
2420 -               close_stderr = 0;
2421 +               srv->errorlog_fd = -1;
2422         }
2423  
2424 -       /* move stderr to /dev/null */
2425 -       if (close_stderr) openDevNull(STDERR_FILENO);
2426 +       if (!buffer_is_empty(srv->srvconf.breakagelog_file)) {
2427 +               int breakage_fd;
2428 +               const char *logfile = srv->srvconf.breakagelog_file->ptr;
2429 +
2430 +               if (srv->errorlog_mode == ERRORLOG_FD) {
2431 +                       srv->errorlog_fd = dup(STDERR_FILENO);
2432 +#ifdef FD_CLOEXEC
2433 +                       fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC);
2434 +#endif
2435 +               }
2436 +
2437 +               if (-1 == (breakage_fd = open_logfile_or_pipe(srv, logfile))) {
2438 +                       return -1;
2439 +               }
2440 +
2441 +               if (STDERR_FILENO != breakage_fd) {
2442 +                       dup2(breakage_fd, STDERR_FILENO);
2443 +                       close(breakage_fd);
2444 +               }
2445 +       } else if (!srv->srvconf.dont_daemonize) {
2446 +               /* move stderr to /dev/null */
2447 +               openDevNull(STDERR_FILENO);
2448 +       }
2449         return 0;
2450  }
2451  
2452 @@ -235,15 +250,19 @@
2453         switch(srv->errorlog_mode) {
2454         case ERRORLOG_PIPE:
2455         case ERRORLOG_FILE:
2456 -               close(srv->errorlog_fd);
2457 +       case ERRORLOG_FD:
2458 +               if (-1 != srv->errorlog_fd) {
2459 +                       /* don't close STDERR */
2460 +                       if (STDERR_FILENO != srv->errorlog_fd)
2461 +                               close(srv->errorlog_fd);
2462 +                       srv->errorlog_fd = -1;
2463 +               }
2464                 break;
2465         case ERRORLOG_SYSLOG:
2466  #ifdef HAVE_SYSLOG_H
2467                 closelog();
2468  #endif
2469                 break;
2470 -       case ERRORLOG_STDERR:
2471 -               break;
2472         }
2473  
2474         return 0;
2475 @@ -255,7 +274,8 @@
2476         switch(srv->errorlog_mode) {
2477         case ERRORLOG_PIPE:
2478         case ERRORLOG_FILE:
2479 -       case ERRORLOG_STDERR:
2480 +       case ERRORLOG_FD:
2481 +               if (-1 == srv->errorlog_fd) return 0;
2482                 /* cache the generated timestamp */
2483                 if (srv->cur_ts != srv->last_generated_debug_ts) {
2484                         buffer_prepare_copy(srv->ts_debug_str, 255);
2485 @@ -349,13 +369,10 @@
2486         switch(srv->errorlog_mode) {
2487         case ERRORLOG_PIPE:
2488         case ERRORLOG_FILE:
2489 +       case ERRORLOG_FD:
2490                 buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n"));
2491                 write(srv->errorlog_fd, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1);
2492                 break;
2493 -       case ERRORLOG_STDERR:
2494 -               buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n"));
2495 -               write(STDERR_FILENO, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1);
2496 -               break;
2497         case ERRORLOG_SYSLOG:
2498                 syslog(LOG_ERR, "%s", srv->errorlog_buf->ptr);
2499                 break;
2500 Index: src/proc_open.c
2501 ===================================================================
2502 --- src/proc_open.c     (.../tags/lighttpd-1.4.23)      (revision 2620)
2503 +++ src/proc_open.c     (.../branches/lighttpd-1.4.x)   (revision 2620)
2504 @@ -309,6 +309,14 @@
2505  
2506         if (err) {
2507                 proc_read_fd_to_buffer(proc.err.fd, err);
2508 +       } else {
2509 +               buffer *tmp = buffer_init();
2510 +               proc_read_fd_to_buffer(proc.err.fd, tmp);
2511 +               if (tmp->used > 0 &&  write(2, (void*)tmp->ptr, tmp->used) < 0) {
2512 +                       perror("error writing pipe");
2513 +                       return -1;
2514 +               }
2515 +               buffer_free(tmp);
2516         }
2517         pipe_close(&proc.err);
2518  
2519 Index: tests/.cvsignore
2520 ===================================================================
2521 Index: tests/bug-12.conf
2522 ===================================================================
2523 --- tests/bug-12.conf   (.../tags/lighttpd-1.4.23)      (revision 2620)
2524 +++ tests/bug-12.conf   (.../branches/lighttpd-1.4.x)   (revision 2620)
2525 @@ -8,6 +8,7 @@
2526  ## bind to localhost (default: all interfaces)
2527  server.bind                = "localhost"
2528  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2529 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2530  server.name                = "www.example.org"
2531  server.tag                 = "Apache 1.3.29"
2532  
2533 Index: tests/fastcgi-10.conf
2534 ===================================================================
2535 --- tests/fastcgi-10.conf       (.../tags/lighttpd-1.4.23)      (revision 2620)
2536 +++ tests/fastcgi-10.conf       (.../branches/lighttpd-1.4.x)   (revision 2620)
2537 @@ -6,6 +6,7 @@
2538  ## bind to localhost (default: all interfaces)
2539  server.bind                = "localhost"
2540  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2541 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2542  server.name                = "www.example.org"
2543  server.tag                 = "Apache 1.3.29"
2544  
2545 Index: tests/bug-06.conf
2546 ===================================================================
2547 --- tests/bug-06.conf   (.../tags/lighttpd-1.4.23)      (revision 2620)
2548 +++ tests/bug-06.conf   (.../branches/lighttpd-1.4.x)   (revision 2620)
2549 @@ -8,6 +8,7 @@
2550  ## bind to localhost (default: all interfaces)
2551  server.bind                = "localhost"
2552  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2553 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2554  server.name                = "www.example.org"
2555  server.tag                 = "Apache 1.3.29"
2556  
2557 Index: tests/mod-extforward.conf
2558 ===================================================================
2559 Index: tests/var-include.conf
2560 ===================================================================
2561 --- tests/var-include.conf      (.../tags/lighttpd-1.4.23)      (revision 2620)
2562 +++ tests/var-include.conf      (.../branches/lighttpd-1.4.x)   (revision 2620)
2563 @@ -10,6 +10,7 @@
2564  ## bind to localhost (default: all interfaces)
2565  server.bind                = "localhost"
2566  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2567 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2568  server.name                = "www.example.org"
2569  server.tag                 = "Apache 1.3.29"
2570  
2571 Index: tests/404-handler.conf
2572 ===================================================================
2573 --- tests/404-handler.conf      (.../tags/lighttpd-1.4.23)      (revision 2620)
2574 +++ tests/404-handler.conf      (.../branches/lighttpd-1.4.x)   (revision 2620)
2575 @@ -10,6 +10,7 @@
2576  ## bind to localhost (default: all interfaces)
2577  server.bind                = "localhost"
2578  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2579 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2580  server.name                = "www.example.org"
2581  server.tag                 = "Apache 1.3.29"
2582  
2583 Index: tests/lowercase.conf
2584 ===================================================================
2585 --- tests/lowercase.conf        (.../tags/lighttpd-1.4.23)      (revision 2620)
2586 +++ tests/lowercase.conf        (.../branches/lighttpd-1.4.x)   (revision 2620)
2587 @@ -6,6 +6,7 @@
2588  ## bind to localhost (default: all interfaces)
2589  server.bind                = "localhost"
2590  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2591 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2592  
2593  server.force-lowercase-filenames = "enable"
2594  
2595 Index: tests/condition.conf
2596 ===================================================================
2597 --- tests/condition.conf        (.../tags/lighttpd-1.4.23)      (revision 2620)
2598 +++ tests/condition.conf        (.../branches/lighttpd-1.4.x)   (revision 2620)
2599 @@ -10,6 +10,7 @@
2600  ## bind to localhost (default: all interfaces)
2601  server.bind                = "localhost"
2602  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2603 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2604  server.name                = "www.example.org"
2605  server.tag                 = "Apache 1.3.29"
2606  
2607 Index: tests/fastcgi-13.conf
2608 ===================================================================
2609 --- tests/fastcgi-13.conf       (.../tags/lighttpd-1.4.23)      (revision 2620)
2610 +++ tests/fastcgi-13.conf       (.../branches/lighttpd-1.4.x)   (revision 2620)
2611 @@ -10,6 +10,7 @@
2612  ## bind to localhost (default: all interfaces)
2613  server.bind                = "localhost"
2614  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2615 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2616  server.name                = "www.example.org"
2617  server.tag                 = "Apache 1.3.29"
2618  
2619 Index: tests/mod-compress.conf
2620 ===================================================================
2621 --- tests/mod-compress.conf     (.../tags/lighttpd-1.4.23)      (revision 2620)
2622 +++ tests/mod-compress.conf     (.../branches/lighttpd-1.4.x)   (revision 2620)
2623 @@ -11,6 +11,7 @@
2624  ## bind to localhost (default: all interfaces)
2625  server.bind                = "localhost"
2626  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2627 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2628  server.name                = "www.example.org"
2629  
2630  server.modules = (
2631 Index: tests/lighttpd.conf
2632 ===================================================================
2633 --- tests/lighttpd.conf (.../tags/lighttpd-1.4.23)      (revision 2620)
2634 +++ tests/lighttpd.conf (.../branches/lighttpd-1.4.x)   (revision 2620)
2635 @@ -13,6 +13,7 @@
2636  ## bind to localhost (default: all interfaces)
2637  server.bind                = "localhost"
2638  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2639 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2640  server.name                = "www.example.org"
2641  server.tag                 = "Apache 1.3.29"
2642  
2643 Index: tests/fastcgi-responder.conf
2644 ===================================================================
2645 --- tests/fastcgi-responder.conf        (.../tags/lighttpd-1.4.23)      (revision 2620)
2646 +++ tests/fastcgi-responder.conf        (.../branches/lighttpd-1.4.x)   (revision 2620)
2647 @@ -15,6 +15,7 @@
2648  ## bind to localhost (default: all interfaces)
2649  server.bind                = "localhost"
2650  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2651 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2652  server.name                = "www.example.org"
2653  server.tag                 = "Apache 1.3.29"
2654  
2655 Index: tests/fastcgi-auth.conf
2656 ===================================================================
2657 --- tests/fastcgi-auth.conf     (.../tags/lighttpd-1.4.23)      (revision 2620)
2658 +++ tests/fastcgi-auth.conf     (.../branches/lighttpd-1.4.x)   (revision 2620)
2659 @@ -12,6 +12,7 @@
2660  ## bind to localhost (default: all interfaces)
2661  server.bind                = "localhost"
2662  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2663 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2664  server.name                = "www.example.org"
2665  server.tag                 = "Apache 1.3.29"
2666  
2667 Index: tests/proxy.conf
2668 ===================================================================
2669 --- tests/proxy.conf    (.../tags/lighttpd-1.4.23)      (revision 2620)
2670 +++ tests/proxy.conf    (.../branches/lighttpd-1.4.x)   (revision 2620)
2671 @@ -6,6 +6,7 @@
2672  ## bind to localhost (default: all interfaces)
2673  server.bind                = "localhost"
2674  server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2675 +server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2676  server.name                = "www.example.org"
2677  server.tag                 = "Proxy"
2678  
2679 Index: tests/LightyTest.pm
2680 ===================================================================
2681 --- tests/LightyTest.pm (.../tags/lighttpd-1.4.23)      (revision 2620)
2682 +++ tests/LightyTest.pm (.../branches/lighttpd-1.4.x)   (revision 2620)
2683 @@ -87,14 +87,21 @@
2684         my $self = shift;
2685         my $port = shift;
2686         my $child = shift;
2687 +       my $timeout = 5*10; # 5 secs, select waits 0.1 s
2688  
2689         while (0 == $self->listening_on($port)) {
2690                 select(undef, undef, undef, 0.1);
2691 +               $timeout--;
2692  
2693                 # the process is gone, we failed
2694                 if (0 != waitpid($child, WNOHANG)) {
2695                         return -1;
2696                 }
2697 +               if (0 >= $timeout) {
2698 +                       diag("Timeout while trying to connect; killing child");
2699 +                       kill('TERM', $child);
2700 +                       return -1;
2701 +               }
2702         }
2703  
2704         return 0;
2705 Index: configure.ac
2706 ===================================================================
2707 --- configure.ac        (.../tags/lighttpd-1.4.23)      (revision 2620)
2708 +++ configure.ac        (.../branches/lighttpd-1.4.x)   (revision 2620)
2709 @@ -1,9 +1,10 @@
2710  #                                               -*- Autoconf -*-
2711  # Process this file with autoconf to produce a configure script.
2712  AC_PREREQ(2.57)
2713 -AC_INIT([lighttpd], [1.4.23], [contact@lighttpd.net])
2714 +AC_INIT([lighttpd], [1.4.24], [contact@lighttpd.net])
2715  AC_CONFIG_SRCDIR([src/server.c])
2716  AC_CONFIG_HEADER([config.h])
2717 +AC_CONFIG_MACRO_DIR([m4])
2718  
2719  AC_CANONICAL_TARGET
2720  
2721 @@ -417,12 +418,18 @@
2722     AC_DEFINE([HAVE_LUA], [1], [liblua])
2723     AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2724   ],[
2725 -   # for debian based systems
2726 -   PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [
2727 -     AC_DEFINE([HAVE_LUA], [1], [liblua])
2728 -     AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2729 -   ])
2730 + # for debian based systems
2731 + PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [
2732 +   AC_DEFINE([HAVE_LUA], [1], [liblua])
2733 +   AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2734 + ],[
2735 + # for freebsd
2736 + PKG_CHECK_MODULES(LUA, lua-5.1 >= 5.1, [
2737 +   AC_DEFINE([HAVE_LUA], [1], [liblua])
2738 +   AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2739   ])
2740 + ])
2741 + ])
2742  
2743   AC_SUBST(LUA_CFLAGS)
2744   AC_SUBST(LUA_LIBS)
2745 Index: doc/.cvsignore
2746 ===================================================================
2747 Index: doc/fastcgi.txt
2748 ===================================================================
2749 --- doc/fastcgi.txt     (.../tags/lighttpd-1.4.23)      (revision 2620)
2750 +++ doc/fastcgi.txt     (.../branches/lighttpd-1.4.x)   (revision 2620)
2751 @@ -95,23 +95,22 @@
2752        (
2753          ( "host" => <string> ,
2754            "port" => <integer> ,
2755 -         "socket" => <string>,       # either socket
2756 -                                     # or host+port
2757 -         "bin-path" => <string>,     # OPTIONAL
2758 -         "bin-environment" => <array>, # OPTIONAL
2759 -         "bin-copy-environment" => <array>, # OPTIONAL
2760 +          "socket" => <string>,       # either socket
2761 +                                      # or host+port
2762 +          "bin-path" => <string>,     # OPTIONAL
2763 +          "bin-environment" => <array>, # OPTIONAL
2764 +          "bin-copy-environment" => <array>, # OPTIONAL
2765            "mode" => <string>,         # OPTIONAL
2766            "docroot" => <string> ,     # OPTIONAL if "mode"
2767 -                                     # is not "authorizer"
2768 +                                      # is not "authorizer"
2769            "check-local" => <string>,  # OPTIONAL
2770 -         "min-procs" => <integer>,   # OPTIONAL
2771 -         "max-procs" => <integer>,   # OPTIONAL
2772 -         "max-load-per-proc" => <integer>, # OPTIONAL
2773 -         "idle-timeout" => <integer>, # OPTIONAL
2774 -         "broken-scriptfilename" => <boolean>, # OPTIONAL
2775 +          "max-procs" => <integer>,   # OPTIONAL
2776 +          "broken-scriptfilename" => <boolean>, # OPTIONAL
2777            "disable-time" => <integer>, # optional
2778 -          "allow-x-send-file" => <boolean> # optional
2779 -       ),
2780 +          "allow-x-send-file" => <boolean>, # optional
2781 +          "kill-signal" => <integer>, # OPTIONAL
2782 +          "fix-root-scriptname" => <boolean>,
2783 +                                      # OPTIONAL
2784          ( "host" => ...
2785          )
2786        )
2787 @@ -127,42 +126,38 @@
2788    :"socket":    path to the unix-domain socket
2789    :"mode":      is the FastCGI protocol mode.
2790                  Default is "responder", also "authorizer"
2791 -               mode is implemented.
2792 +                mode is implemented.
2793    :"docroot":   is optional and is the docroot on the remote
2794                  host for default "responder" mode. For
2795 -               "authorizer" mode it is MANDATORY and it points
2796 -               to docroot for authorized requests. For security
2797 -               reasons it is recommended to keep this docroot
2798 +                "authorizer" mode it is MANDATORY and it points
2799 +                to docroot for authorized requests. For security
2800 +                reasons it is recommended to keep this docroot
2801                  outside of server.document-root tree.
2802    :"check-local": is optional and may be "enable" (default) or
2803                  "disable". If enabled the server first check
2804 -               for a file in local server.document-root tree
2805 -               and return 404 (Not Found) if no such file.
2806 +                for a file in local server.document-root tree
2807 +                and return 404 (Not Found) if no such file.
2808                  If disabled, the server forward request to
2809 -               FastCGI interface without this check.
2810 +                FastCGI interface without this check.
2811    :"broken-scriptfilename": breaks SCRIPT_FILENAME in a wat that
2812                  PHP can extract PATH_INFO from it (default: disabled)
2813    :"disable-time": time to wait before a disabled backend is checked
2814                  again
2815    :"allow-x-send-file": controls if X-LIGHTTPD-send-file headers
2816                  are allowed
2817 +  :"fix-root-scriptname": fix broken path-info split for "/" extension ("prefix")
2818  
2819    If bin-path is set:
2820  
2821 -  :"min-procs": sets the minium processes to start
2822    :"max-procs": the upper limit of the processess to start
2823 -  :"max-load-per-proc": maximum number of waiting processes on
2824 -                average per process before a new process is
2825 -                spawned
2826 -  :"idle-timeout": number of seconds before a unused process
2827 -                gets terminated
2828    :"bin-environment": put an entry into the environment of
2829                  the started process
2830    :"bin-copy-environement": clean up the environment and copy
2831                  only the specified entries into the fresh
2832                  environment of the spawn process
2833 +  :"kill-signal": signal to terminate the FastCGI process with,
2834 +                defauls to SIGTERM
2835  
2836 -
2837  Examples
2838  --------
2839  
2840 @@ -171,11 +166,11 @@
2841      fastcgi.server = ( ".php" =>
2842        (( "host" => "127.0.0.1",
2843           "port" => 1026,
2844 -        "bin-path" => "/usr/local/bin/php"
2845 +         "bin-path" => "/usr/local/bin/php"
2846        )),
2847        ".php4" =>
2848        (( "host" => "127.0.0.1",
2849 -        "port" => 1026
2850 +         "port" => 1026
2851        ))
2852      )
2853  
2854 @@ -183,10 +178,10 @@
2855  
2856      fastcgi.server = ( "/remote_scripts/" =>
2857        (( "host" => "192.168.0.3",
2858 -        "port" => 9000,
2859 +         "port" => 9000,
2860           "check-local" => "disable",
2861           "docroot" => "/" # remote server may use
2862 -                         # it's own docroot
2863 +                          # it's own docroot
2864        ))
2865      )
2866  
2867 @@ -206,7 +201,7 @@
2868  
2869      fastcgi.server = ( "/remote_scripts/" =>
2870        (( "host" => "10.0.0.2",
2871 -        "port" => 9000,
2872 +         "port" => 9000,
2873           "docroot" => "/path_to_private_docs",
2874           "mode" => "authorizer"
2875        ))
2876 @@ -318,10 +313,10 @@
2877       $ PHP_FCGI_CHILDREN=384 ./lighttpd -f ./lighttpd.conf
2878  
2879       fastcgi.server = ( ".php" =>
2880 -       (( "socket" => "/tmp/php.socket",
2881 +        (( "socket" => "/tmp/php.socket",
2882             "bin-path" => "/usr/local/bin/php",
2883             "min-procs" => 1,
2884 -          "max-procs" => 1,
2885 +           "max-procs" => 1,
2886             "max-load-per-proc" => 4,
2887             "idle-timeout" => 20
2888          ))
2889 @@ -408,7 +403,7 @@
2890             "PHP_FCGI_CHILDREN" => "16",
2891             "PHP_FCGI_MAX_REQUESTS" => "10000" ),
2892          "bin-copy-environment" => (
2893 -          "PATH", "SHELL", "USER" )
2894 +           "PATH", "SHELL", "USER" )
2895       ))
2896     )
2897  
2898 Index: SConstruct
2899 ===================================================================
2900 Index: Makefile.am
2901 ===================================================================
2902 --- Makefile.am (.../tags/lighttpd-1.4.23)      (revision 2620)
2903 +++ Makefile.am (.../branches/lighttpd-1.4.x)   (revision 2620)
2904 @@ -2,4 +2,6 @@
2905  
2906  EXTRA_DIST=autogen.sh SConstruct
2907  
2908 +ACLOCAL_AMFLAGS = -I m4
2909 +
2910  distcleancheck_listfiles = find -type f -exec sh -c 'test -f $(srcdir)/{} || echo {}' ';'
2911 Index: autogen.sh
2912 ===================================================================
2913 --- autogen.sh  (.../tags/lighttpd-1.4.23)      (revision 2620)
2914 +++ autogen.sh  (.../branches/lighttpd-1.4.x)   (revision 2620)
2915 @@ -1,27 +1,92 @@
2916  #!/bin/sh
2917  # Run this to generate all the initial makefiles, etc.
2918  
2919 -LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
2920  LIBTOOLIZE_FLAGS="--copy --force"
2921 -ACLOCAL=${ACLOCAL:-aclocal}
2922 -AUTOHEADER=${AUTOHEADER:-autoheader}
2923 -AUTOMAKE=${AUTOMAKE:-automake}
2924 -AUTOMAKE_FLAGS="--add-missing --copy"
2925 -AUTOCONF=${AUTOCONF:-autoconf}
2926 +AUTOMAKE_FLAGS="--add-missing --copy --foreign"
2927  
2928  ARGV0=$0
2929 +ARGS="$@"
2930  
2931 -set -e
2932  
2933 -
2934  run() {
2935 -       echo "$ARGV0: running \`$@'"
2936 -       $@
2937 +       echo "$ARGV0: running \`$@' $ARGS"
2938 +       $@ $ARGS
2939  }
2940  
2941 +## jump out if one of the programs returns 'false'
2942 +set -e
2943 +
2944 +## on macosx glibtoolize, others have libtool
2945 +if test x$LIBTOOLIZE = x; then
2946 +  if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then
2947 +    LIBTOOLIZE=glibtoolize
2948 +  elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then
2949 +    LIBTOOLIZE=libtoolize-1.5
2950 +  elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then
2951 +    LIBTOOLIZE=libtoolize
2952 +  else 
2953 +    echo "libtoolize 1.5.x wasn't found, exiting"; exit 0
2954 +  fi
2955 +fi
2956 +
2957 +## suse has aclocal and aclocal-1.9
2958 +if test x$ACLOCAL = x; then
2959 +  if test \! "x`which aclocal-1.9 2> /dev/null | grep -v '^no'`" = x; then
2960 +    ACLOCAL=aclocal-1.9
2961 +  elif test \! "x`which aclocal19 2> /dev/null | grep -v '^no'`" = x; then
2962 +    ACLOCAL=aclocal19
2963 +  elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then
2964 +    ACLOCAL=aclocal
2965 +  else 
2966 +    echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0
2967 +  fi
2968 +fi
2969 +
2970 +if test x$AUTOMAKE = x; then
2971 +  if test \! "x`which automake-1.9 2> /dev/null | grep -v '^no'`" = x; then
2972 +    AUTOMAKE=automake-1.9
2973 +  elif test \! "x`which automake19 2> /dev/null | grep -v '^no'`" = x; then
2974 +    AUTOMAKE=automake19
2975 +  elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then
2976 +    AUTOMAKE=automake
2977 +  else 
2978 +    echo "automake 1.9.x wasn't found, exiting"; exit 0
2979 +  fi
2980 +fi
2981 +
2982 +
2983 +## macosx has autoconf-2.59 and autoconf-2.60
2984 +if test x$AUTOCONF = x; then
2985 +  if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then
2986 +    AUTOCONF=autoconf-2.59
2987 +  elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then
2988 +    AUTOCONF=autoconf259
2989 +  elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then
2990 +    AUTOCONF=autoconf
2991 +  else 
2992 +    echo "autoconf 2.59+ wasn't found, exiting"; exit 0
2993 +  fi
2994 +fi
2995 +
2996 +if test x$AUTOHEADER = x; then
2997 +  if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then
2998 +    AUTOHEADER=autoheader-2.59
2999 +  elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then
3000 +    AUTOHEADER=autoheader259
3001 +  elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then
3002 +    AUTOHEADER=autoheader
3003 +  else 
3004 +    echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0
3005 +  fi
3006 +fi
3007 +
3008 +mkdir -p m4
3009  run $LIBTOOLIZE $LIBTOOLIZE_FLAGS
3010 -run $ACLOCAL $ACLOCAL_FLAGS
3011 +run $ACLOCAL $ACLOCAL_FLAGS -I m4
3012  run $AUTOHEADER
3013  run $AUTOMAKE $AUTOMAKE_FLAGS
3014  run $AUTOCONF
3015 -echo "Now type './configure ...' and 'make' to compile."
3016 +
3017 +if test "$ARGS" = "" ; then
3018 +  echo "Now type './configure ...' and 'make' to compile."
3019 +fi
3020 Index: NEWS
3021 ===================================================================
3022 --- NEWS        (.../tags/lighttpd-1.4.23)      (revision 2620)
3023 +++ NEWS        (.../branches/lighttpd-1.4.x)   (revision 2620)
3024 @@ -3,7 +3,41 @@
3025  NEWS
3026  ====
3027  
3028 -- 1.4.23 -
3029 +- 1.4.24 -
3030 +  * Add T_CONFIG_INT for bigger integers from the config (needed for #1966)
3031 +  * Use unsigned int (and T_CONFIG_INT) for max_request_size
3032 +  * Use unsigned int for secdownload.timeout (fixes #1966)
3033 +  * Keep url/host values from connection to display information while keep-alive in mod_status (fixes #1202)
3034 +  * Add server.breakagelog, a "special" stderr (fixes #1863)
3035 +  * Fix config evaluation for debug.log-timeouts option (#1529)
3036 +  * Add "cgi.execute-x-only" to mod_cgi, requires +x for cgi scripts (fixes #2013)
3037 +  * Fix FD_SETSIZE comparision warnings
3038 +  * Add "lua-5.1" to searched pkg-config names for lua
3039 +  * Fix unused function webdav_lockdiscovery in mod_webdav
3040 +  * cmake: Fix crypt lib check
3041 +  * cmake: Add -export-dynamic to link flags, fixes build on FreeBSD
3042 +  * Set FD_CLOEXEC for bound sockets before pipe-logger forks (fixes #2026)
3043 +  * Reset ignored signals to SIG_DFL before exec() in fastcgi/scgi (fixes #2029)
3044 +  * Show "no uri specified -> 400" error only when "debug.log-request-header-on-error" is enabled (fixes #2030)
3045 +  * Fix hanging connection in mod_scgi (fixes #2024)
3046 +  * Allow digits in hostnames in more places (fixes #1148)
3047 +  * Use connection_reset instead of handle_request_done for cleanup callbacks
3048 +  * Change mod_expire to append Cache-Control instead of overwriting it (fixes #1997)
3049 +  * Allow all comparisons for $SERVER["socket"] - only bind for "=="
3050 +  * Remove strptime failed message (fixes #2031)
3051 +  * Fix issues found with clang analyzer
3052 +  * Try to fix server.tag issue with localized svnversion
3053 +  * Fix handling network-write return values (#2024)
3054 +  * Use disable-time in fastcgi for all disables after errors, default is 1sec (fixes #2040)
3055 +  * Remove adaptive spawning code from fastcgi (was disabled for a long time)
3056 +  * Allow mod_mysql_vhost to use stored procedures (fixes #2011, thx Ben Brown)
3057 +  * Fix ipv6 in mod_proxy (fixes #2043)
3058 +  * Print errors from include_shell to stderr
3059 +  * Set tm.tm_isdst = 0 before mktime() (fixes #2047)
3060 +  * Use linux-epoll by default if available (fixes #2021, thx Olaf van der Spek)
3061 +  * Print an error if you use too many captures in a regex pattern (fixes #2059)
3062 +
3063 +- 1.4.23 - 2009-06-19
3064    * Added some extra warning options in cmake and fix the resulting warnings (unused/static functions)
3065    * New lighttpd man page (moved it to section 8) (fixes #1875)
3066    * Create rrd file for empty rrdfile in mod_rrdtool (#1788)
3067 Index: CMakeLists.txt
3068 ===================================================================
This page took 0.556801 seconds and 4 git commands to generate.