2 ===================================================================
4 ===================================================================
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)
12 if (e != ds->value->ptr && !*e && l >=0 && l <= 65535) {
13 *((unsigned short *)(cv[i].destination)) = l;
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");
30 + case TYPE_INTEGER: {
31 + data_integer *di = (data_integer *)du;
33 + *((unsigned int *)(cv[i].destination)) = di->value;
37 + data_string *ds = (data_string *)du;
39 + if (ds->value->ptr && *ds->value->ptr) {
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;
49 + log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an integer:", cv[i].key, ds->value);
54 + log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected an integer, range 0 ... 4294967295");
58 case T_CONFIG_BOOLEAN:
59 if (du->type == TYPE_STRING) {
60 data_string *ds = (data_string *)du;
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)
69 + unsigned short execute_x_only;
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}
84 s->cgi = array_init();
85 + s->execute_x_only = 0;
87 cv[0].destination = s->cgi;
88 + cv[1].destination = &(s->execute_x_only);
90 p->config_storage[i] = s;
94 log_error_write(srv, __FILE__, __LINE__, "sd", "(debug) cgi exited fine, pid:", pid);
100 log_error_write(srv, __FILE__, __LINE__, "sd", "cgi died, pid:", pid);
102 return HANDLER_GO_ON;
105 @@ -1005,7 +1006,7 @@
106 args[i++] = cgi_handler->ptr;
108 args[i++] = con->physical.path->ptr;
112 /* search for the last / */
113 if (NULL != (c = strrchr(con->physical.path->ptr, '/'))) {
114 @@ -1018,8 +1019,6 @@
118 - openDevNull(STDERR_FILENO);
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 @@
125 if (buffer_is_equal_string(du->key, CONST_STR_LEN("cgi.assign"))) {
127 + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("cgi.execute-x-only"))) {
128 + PATCH(execute_x_only);
132 @@ -1220,6 +1221,7 @@
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;
138 s_len = fn->used - 1;
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)
145 toSend = c->mem->used - 1 - c->offset;
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);
155 if ((r = write(fd, offset, toSend)) < 0) {
156 - log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed: ", strerror(errno), fd);
166 + log_error_write(srv, __FILE__, __LINE__, "ssd",
167 + "write failed:", strerror(errno), fd);
179 -#if defined 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));
184 @@ -109,13 +121,26 @@
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);
198 + munmap(p, sce->st.st_size);
201 + log_error_write(srv, __FILE__, __LINE__, "ssd",
202 + "write failed:", strerror(errno), fd);
203 + munmap(p, sce->st.st_size);
209 munmap(p, sce->st.st_size);
211 +#else /* USE_MMAP */
212 buffer_prepare_copy(srv->tmp_buf, toSend);
214 lseek(ifd, offset, SEEK_SET);
215 @@ -127,12 +152,33 @@
219 - if (-1 == (r = send(fd, srv->tmp_buf->ptr, toSend, 0))) {
220 - log_error_write(srv, __FILE__, __LINE__, "ss", "write: ", strerror(errno));
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);
230 + if ((r = write(fd, srv->tmp_buf->ptr, toSend)) < 0) {
240 + log_error_write(srv, __FILE__, __LINE__, "ssd",
241 + "write failed:", strerror(errno), fd);
246 +#endif /* __WIN32 */
247 +#endif /* USE_MMAP */
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)
260 - unsigned short timeout;
261 + unsigned int timeout;
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 }
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;
286 ===================================================================
287 --- src/base.h (.../tags/lighttpd-1.4.23) (revision 2620)
288 +++ src/base.h (.../branches/lighttpd-1.4.x) (revision 2620)
290 typedef enum { T_CONFIG_UNSET,
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;
304 unsigned short kbytes_per_second; /* connection kb/s limit */
308 buffer *errorlog_file;
309 unsigned short errorlog_use_syslog;
310 + buffer *breakagelog_file;
312 unsigned short dont_daemonize;
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;
321 unsigned short log_request_header_on_error;
322 unsigned short log_state_handling;
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;
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)
339 if (NULL != (du = array_get_element(ca, option))) {
340 - data_array *da = (data_array *)du;
344 if (du->type != TYPE_ARRAY) {
354 @@ -383,17 +383,15 @@
356 buffer_reset(con->request.uri);
358 - start = 0; end = pattern_len;
360 for (k = 0; k < pattern_len; k++) {
361 if (pattern[k] == '$' || pattern[k] == '%') {
364 size_t num = pattern[k + 1] - '0';
367 + buffer_append_string_len(con->request.uri, pattern + start, k - start);
369 - buffer_append_string_len(con->request.uri, pattern + start, end - start);
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);
382 - CLEAN(request.orig_uri);
383 + /* CLEAN(request.orig_uri); */
386 - CLEAN(uri.authority);
388 + /* CLEAN(uri.authority); */
389 + /* CLEAN(uri.path); */
392 + /* CLEAN(uri.query); */
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));
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);
405 if (http_request_parse(srv, con)) {
406 /* we have to read some data from the POST request */
408 @@ -1725,7 +1730,7 @@
409 case HANDLER_FINISHED:
412 - log_error_write(srv, __FILE__, __LINE__, "");
413 + log_error_write(srv, __FILE__, __LINE__, "sd", "unhandling return value", r);
418 ===================================================================
419 --- src/network.c (.../tags/lighttpd-1.4.23) (revision 2620)
420 +++ src/network.c (.../branches/lighttpd-1.4.x) (revision 2620)
423 srv_socket = calloc(1, sizeof(*srv_socket));
425 + srv_socket->fde_ndx = -1;
427 srv_socket->srv_token = buffer_init();
428 buffer_copy_string_buffer(srv_socket->srv_token, host_token);
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);
434 + goto error_free_socket;
439 } else if (port == 0 || port > 65535) {
440 log_error_write(srv, __FILE__, __LINE__, "sd", "port out of range:", port);
443 + goto error_free_socket;
446 if (*host == '\0') host = NULL;
447 @@ -138,12 +139,12 @@
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));
452 + goto error_free_socket;
455 log_error_write(srv, __FILE__, __LINE__, "s",
456 "ERROR: Unix Domain sockets are not supported.");
458 + goto error_free_socket;
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));
467 + goto error_free_socket;
469 srv_socket->use_ipv6 = 1;
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));
476 + goto error_free_socket;
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);
486 srv->cur_fds = srv_socket->fd;
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));
492 + goto error_free_socket;
495 switch(srv_socket->addr.plain.sa_family) {
497 "sssss", "getaddrinfo failed: ",
498 gai_strerror(r), "'", host, "'");
501 + goto error_free_socket;
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: ",
510 + goto error_free_socket;
513 if (he->h_addrtype != AF_INET) {
514 log_error_write(srv, __FILE__, __LINE__, "sd", "addr-type != AF_INET: ", he->h_addrtype);
516 + goto error_free_socket;
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);
522 + goto error_free_socket;
525 memcpy(&(srv_socket->addr.ipv4.sin_addr.s_addr), he->h_addr_list[0], he->h_length);
531 + goto error_free_socket;
535 @@ -275,14 +281,12 @@
536 "testing socket failed:",
537 host, strerror(errno));
540 + goto error_free_socket;
548 + goto error_free_socket;
551 if (0 != bind(srv_socket->fd, (struct sockaddr *) &(srv_socket->addr), addr_len)) {
552 @@ -298,12 +302,12 @@
553 host, port, strerror(errno));
557 + goto error_free_socket;
560 if (-1 == listen(srv_socket->fd, 128 * 8)) {
561 log_error_write(srv, __FILE__, __LINE__, "ss", "listen failed: ", strerror(errno));
563 + goto error_free_socket;
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");
572 + goto error_free_socket;
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));
580 + goto error_free_socket;
583 if (!s->ssl_use_sslv2) {
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));
589 + goto error_free_socket;
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));
598 + goto error_free_socket;
602 if (buffer_is_empty(s->ssl_pemfile)) {
603 log_error_write(srv, __FILE__, __LINE__, "s", "ssl.pemfile has to be set");
605 + goto error_free_socket;
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);
613 + goto error_free_socket;
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);
621 + goto error_free_socket;
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);
628 + goto error_free_socket;
631 if (SSL_CTX_check_private_key(s->ssl_ctx) != 1) {
633 "Private key does not match the certificate public key, reason:",
634 ERR_error_string(ERR_get_error(), NULL),
637 + goto error_free_socket;
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);
642 log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",
643 "ssl requested but openssl support is not compiled in");
646 + goto error_free_socket;
648 #ifdef TCP_DEFER_ACCEPT
649 } else if (s->defer_accept) {
653 srv_socket->is_ssl = s->is_ssl;
654 - srv_socket->fde_ndx = -1;
656 if (srv->srv_sockets.size == 0) {
657 srv->srv_sockets.size = 4;
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);
671 + close(srv_socket->fd);
673 + buffer_free(srv_socket->srv_token);
679 int network_close(server *srv) {
682 if (COMP_SERVER_SOCKET != dc->comp) continue;
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;
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)
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 */
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 },
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;
738 srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
740 assert(srv->config_storage);
742 PATCH(log_condition_handling);
743 PATCH(log_file_not_found);
744 PATCH(log_ssl_noise);
745 + PATCH(log_timeouts);
747 PATCH(range_requests);
748 PATCH(force_lowercase_filenames);
749 @@ -1135,15 +1139,15 @@
750 * - select works everywhere
751 * - linux-* are experimental
753 +#ifdef USE_LINUX_EPOLL
754 + { FDEVENT_HANDLER_LINUX_SYSEPOLL, "linux-sysepoll" },
757 { FDEVENT_HANDLER_POLL, "poll" },
760 { FDEVENT_HANDLER_SELECT, "select" },
762 -#ifdef USE_LINUX_EPOLL
763 - { FDEVENT_HANDLER_LINUX_SYSEPOLL, "linux-sysepoll" },
765 #ifdef USE_LINUX_SIGIO
766 { FDEVENT_HANDLER_LINUX_RTSIG, "linux-rtsig" },
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)
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);
780 array_insert_unique(host,(data_unset *)ds);
781 @@ -294,10 +294,10 @@
782 char *colon = strchr(con->uri.authority->ptr, ':');
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 */
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 */
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)
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;
805 if (t == NULL) return t;
806 N.left = N.right = NULL;
808 - root_size = node_size(t);
813 ===================================================================
814 --- src/lemon.c (.../tags/lighttpd-1.4.23) (revision 2620)
815 +++ src/lemon.c (.../branches/lighttpd-1.4.x) (revision 2620)
821 +#define NORETURN __attribute__ ((__noreturn__))
826 /* #define PRIVATE static */
827 #define PRIVATE static
831 extern void *malloc();
833 -extern void memory_error();
834 +extern void memory_error() NORETURN;
836 /******** From the file "action.h" *************************************/
837 struct action *Action_new();
841 /********* From the file "assert.h" ************************************/
843 +void myassert() NORETURN;
845 # define assert(X) if(!(X))myassert(__FILE__,__LINE__)
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
851 -void memory_error(){
852 +void memory_error() {
853 fprintf(stderr,"Out of memory. Aborting...\n");
856 @@ -1608,7 +1614,6 @@
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 @@
866 ErrorMsg(ps.filename,0,"Can't allocate %d of memory to hold this file.",
872 @@ -2343,6 +2349,7 @@
873 ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.",
880 @@ -2913,7 +2920,7 @@
881 }else if( sp->destructor ){
883 fprintf(out,"#line %d \"%s\"\n{",sp->destructorln,lemp->filename);
884 - }else if( lemp->vardest ){
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 */
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)
904 int scgi_proclist_sort_down(server *srv, scgi_extension_host *host, scgi_proc *proc);
906 +static void reset_signals(void) {
908 + signal(SIGTTOU, SIG_DFL);
911 + signal(SIGTTIN, SIG_DFL);
914 + signal(SIGTSTP, SIG_DFL);
916 + signal(SIGHUP, SIG_DFL);
917 + signal(SIGPIPE, SIG_DFL);
918 + signal(SIGUSR1, SIG_DFL);
922 static handler_ctx * handler_ctx_init() {
935 /* we don't need the client socket */
940 - openDevNull(STDERR_FILENO);
942 /* build clean environment */
943 if (host->bin_env_copy->used) {
944 for (i = 0; i < host->bin_env_copy->used; i++) {
946 buffer_copy_string_len(b, CONST_STR_LEN("exec "));
947 buffer_append_string_buffer(b, host->bin_path);
952 execle("/bin/sh", "sh", "-c", b->ptr, (char *)NULL, env.ptr);
954 @@ -2163,8 +2174,11 @@
959 - ((!host->host->used || !host->port) && !host->unixsocket->used)) {
961 + log_error_write(srv, __FILE__, __LINE__, "s", "fatal error: host = NULL");
962 + return HANDLER_ERROR;
964 + if (((!host->host->used || !host->port) && !host->unixsocket->used)) {
965 log_error_write(srv, __FILE__, __LINE__, "sxddd",
968 @@ -2299,8 +2313,8 @@
970 chunkqueue_remove_finished_chunks(hctx->wb);
973 - if (errno == ENOTCONN) {
975 + if (errno == ENOTCONN || ret == -2) {
976 /* the connection got dropped after accept()
978 * this is most of the time a PHP which dies
979 @@ -2325,24 +2339,17 @@
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);
988 return HANDLER_ERROR;
991 - if ((errno != EAGAIN) &&
992 - (errno != EINTR)) {
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);
1000 return HANDLER_ERROR;
1002 - fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
1004 - return HANDLER_WAIT_FOR_EVENT;
1008 @@ -2469,12 +2476,10 @@
1011 static handler_t scgi_connection_close(server *srv, handler_ctx *hctx) {
1015 if (NULL == hctx) return HANDLER_GO_ON;
1017 - p = hctx->plugin_data;
1018 con = hctx->remote_conn;
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++) {
1025 + scgi_extension *ext = p->conf.exts->exts[k];
1027 - extension = p->conf.exts->exts[k];
1028 + if (ext->key->used == 0) continue;
1030 - if (extension->key->used == 0) continue;
1031 + ct_len = ext->key->used - 1;
1033 - ct_len = extension->key->used - 1;
1035 if (s_len < ct_len) continue;
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) {
1044 - } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
1046 + } else if (0 == strncmp(fn->ptr + s_len - ct_len, ext->key->ptr, ct_len)) {
1047 /* check extension in the form ".fcg" */
1053 /* extension doesn't match */
1054 - if (k == p->conf.exts->used) {
1055 + if (NULL == extension) {
1056 return HANDLER_GO_ON;
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 @@
1065 #define FOO(x) (s->x->used ? s->x->ptr : NULL)
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)) {
1072 + if (!mysql_real_connect(s->mysql, FOO(hostname), FOO(myuser), FOO(mypass),
1073 FOO(mydb), s->port, FOO(mysock), 0)) {
1075 log_error_write(srv, __FILE__, __LINE__, "s", mysql_error(s->mysql));
1077 return HANDLER_ERROR;
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);
1085 return HANDLER_GO_ON;
1089 c->fcgi_offset = c->fcgi_arg->used = 0;
1091 mysql_free_result(result);
1092 +#if MYSQL_VERSION_ID >= 40100
1093 + while (mysql_next_result(p->conf.mysql) == 0);
1096 /* fix virtual server and docroot */
1097 GO_ON: buffer_copy_string_buffer(con->server_name, c->server_name);
1099 return HANDLER_GO_ON;
1101 ERR500: if (result) mysql_free_result(result);
1102 +#if MYSQL_VERSION_ID >= 40100
1103 + while (mysql_next_result(p->conf.mysql) == 0);
1105 con->http_status = 500; /* Internal Error */
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");
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;
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;
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");
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)
1146 /* check the first character at right of the dot */
1148 - if (!light_isalpha(host->ptr[i+1])) {
1149 + if (!light_isalnum(host->ptr[i+1])) {
1152 } else if (!light_isdigit(host->ptr[i+1])) {
1155 } else if (i == 0) {
1156 /* the first character of the hostname */
1157 - if (!light_isalpha(c)) {
1158 + if (!light_isalnum(c)) {
1163 con->response.keep_alive = 0;
1164 con->keep_alive = 0;
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)
1181 + * >= 0 : chunks completed
1182 + * -1 : error (on our side)
1183 + * -2 : remote close
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 @@
1194 args[i++] = p->conf.path_rrdtool_bin->ptr;
1199 - openDevNull(STDERR_FILENO);
1201 /* we don't need the client socket */
1202 for (i = 3; i < 256; i++) {
1205 "RRA:MIN:0.5:24:775 "
1206 "RRA:MIN:0.5:288:797\n"));
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));
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 @@
1222 +#ifdef DEBUG_STAT_CACHE
1223 + int osize = splaytree_size(sc->files);
1227 - osize = sc->files->size;
1230 sce = stat_cache_entry_init();
1231 buffer_copy_string_buffer(sce->name, name);
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 @@
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;
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 @@
1256 chunkqueue_remove_finished_chunks(hctx->wb);
1259 - if (errno != EAGAIN &&
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);
1265 - return HANDLER_ERROR;
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);
1272 - return HANDLER_WAIT_FOR_EVENT;
1274 + return HANDLER_WAIT_FOR_EVENT;
1277 if (hctx->wb->bytes_out == hctx->wb->bytes_in) {
1278 @@ -1107,19 +1107,20 @@
1280 /* check if extension matches */
1281 for (k = 0; k < p->conf.extensions->used; k++) {
1282 + data_array *ext = NULL;
1285 - extension = (data_array *)p->conf.extensions->data[k];
1286 + ext = (data_array *)p->conf.extensions->data[k];
1288 - if (extension->key->used == 0) continue;
1289 + if (ext->key->used == 0) continue;
1291 - ct_len = extension->key->used - 1;
1292 + ct_len = ext->key->used - 1;
1294 if (s_len < ct_len) continue;
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) {
1304 @@ -1127,15 +1128,17 @@
1305 path_info_offset = pi_offset - fn->ptr;
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" */
1319 - if (k == p->conf.extensions->used) {
1320 + if (NULL == extension) {
1321 return HANDLER_GO_ON;
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)
1330 @test -f versionstamp.h || touch versionstamp.h; \
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 \
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)"; \
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)
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 */
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));
1357 return HANDLER_GO_ON;
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 @@
1376 + char *username = NULL;
1377 + char *realm = NULL;
1378 + char *nonce = NULL;
1380 + char *algorithm = NULL;
1382 + char *cnonce = NULL;
1384 + char *respons = NULL;
1387 const char *m = NULL;
1388 @@ -967,15 +967,9 @@
1389 dkv[6].ptr = &cnonce;
1391 dkv[8].ptr = &respons;
1392 - dkv[9].ptr = NULL;
1396 - for (i = 0; dkv[i].key; i++) {
1397 - *(dkv[i].ptr) = NULL;
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)
1412 - size_t start, end;
1417 @@ -213,17 +213,15 @@
1419 buffer_reset(p->location);
1421 - start = 0; end = pattern_len;
1423 for (k = 0; k < pattern_len; k++) {
1424 if (pattern[k] == '$' || pattern[k] == '%') {
1427 size_t num = pattern[k + 1] - '0';
1430 + buffer_append_string_len(p->location, pattern + start, k - start);
1432 - buffer_append_string_len(p->location, pattern + start, end - start);
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 @@
1446 static int webdav_lockdiscovery(server *srv, connection *con,
1447 buffer *locktoken, const char *lockscope, const char *locktype, int depth) {
1449 @@ -1150,6 +1151,8 @@
1456 * check if resource is having the right locks to access to resource
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)
1464 return (data_unset *)ds;
1466 - fprintf(stderr, "data type mismatch, cannot be merge\n");
1467 + fprintf(stderr, "data type mismatch, cannot merge\n");
1472 du = configparser_merge_data(du, B);
1478 buffer_copy_string_buffer(du->key, A);
1480 case CONFIG_COND_MATCH: {
1484 + int erroff, captures;
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);
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",
1496 + } else if (captures > 9) {
1497 + fprintf(stderr, "Too many captures in regex, use (?:...) instead of (...): %s\n",
1501 dc->string = buffer_init_buffer(rvalue);
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)
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 @@
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;
1523 + if (CON_STATE_READ == c->state && c->request.orig_uri->used > 0) {
1526 + state = connection_get_short_state(c->state);
1529 buffer_append_string_len(b, state, 1);
1531 if (((j + 1) % 50) == 0) {
1532 @@ -497,7 +503,11 @@
1534 buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">"));
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"));
1540 + buffer_append_string(b, connection_get_state(c->state));
1543 buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">"));
1545 @@ -611,10 +621,10 @@
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;
1553 array *st = srv->status;
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)
1566 - int var = 0, enc = 0;
1568 + /* int enc = 0; */
1569 const char *var_val = NULL;
1570 stat_cache_entry *sce = NULL;
1573 { NULL, SSI_ECHO_UNSET }
1579 enum { SSI_ENC_UNSET, SSI_ENC_URL, SSI_ENC_NONE, SSI_ENC_ENTITY } type;
1582 { NULL, SSI_ENC_UNSET }
1586 for (i = 2; i < n; i += 2) {
1587 if (0 == strcmp(l[i], "var")) {
1591 } else if (0 == strcmp(l[i], "encoding")) {
1595 for (j = 0; encvars[j].var; j++) {
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)
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;
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;
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)
1634 +#include <string.h>
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)
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;
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';
1656 if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
1657 con->http_status = 412;
1659 return HANDLER_FINISHED;
1662 t_header = mktime(&tm);
1664 strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
1666 t_file = mktime(&tm);
1668 if (t_file > t_header) return HANDLER_GO_ON;
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;
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';
1683 if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
1685 * parsing failed, let's get out of here
1687 - log_error_write(srv, __FILE__, __LINE__, "ss",
1688 - "strptime() failed on", buf);
1689 return HANDLER_GO_ON;
1692 t_header = mktime(&tm);
1694 strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
1696 t_file = mktime(&tm);
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)
1704 return HANDLER_GO_ON;
1707 -REQUESTDONE_FUNC(mod_setenv_reset) {
1708 +CONNECTION_FUNC(mod_setenv_reset) {
1709 plugin_data *p = p_d;
1713 p->set_defaults = mod_setenv_set_defaults;
1714 p->cleanup = mod_setenv_free;
1716 - p->handle_request_done = mod_setenv_reset;
1717 + p->connection_reset = mod_setenv_reset;
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 @@
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 */
1734 - unsigned short max_load_per_proc;
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.
1744 - unsigned short idle_timeout;
1747 * time after a disabled remote connection is tried to be re-enabled
1750 @@ -384,6 +371,21 @@
1751 /* ok, we need a prototype */
1752 static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents);
1754 +static void reset_signals(void) {
1756 + signal(SIGTTOU, SIG_DFL);
1759 + signal(SIGTTIN, SIG_DFL);
1762 + signal(SIGTSTP, SIG_DFL);
1764 + signal(SIGHUP, SIG_DFL);
1765 + signal(SIGPIPE, SIG_DFL);
1766 + signal(SIGUSR1, SIG_DFL);
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);
1776 - openDevNull(STDERR_FILENO);
1778 /* we don't need the client socket */
1779 for (i = 3; i < 256; i++) {
1781 @@ -1054,6 +1054,7 @@
1788 execve(arg.ptr[0], arg.ptr, env.ptr);
1789 @@ -1235,20 +1236,17 @@
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 */
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 */
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 */
1817 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
1819 @@ -1267,12 +1265,9 @@
1820 buffer_copy_string_buffer(host->id, da_host->key);
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 @@
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);
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);
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 */
1866 - /* HACK: just to make sure the adaptive spawing is disabled */
1867 - host->min_procs = host->max_procs;
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;
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);
1883 - for (pno = 0; pno < host->min_procs; pno++) {
1884 + for (pno = 0; pno < host->max_procs; pno++) {
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);
1896 if (fcgi_spawn_connection(srv, p, host, proc)) {
1897 @@ -1426,7 +1411,6 @@
1901 - host->min_procs = 1;
1902 host->max_procs = 1;
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);
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)
1919 - (!host->port && !host->unixsocket->used)) {
1921 + log_error_write(srv, __FILE__, __LINE__, "s", "fatal error: host = NULL");
1922 + return HANDLER_ERROR;
1924 + if ((!host->port && !host->unixsocket->used)) {
1925 log_error_write(srv, __FILE__, __LINE__, "sxddd",
1928 @@ -2787,7 +2774,7 @@
1930 host->unixsocket->used);
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;
1936 return HANDLER_ERROR;
1937 @@ -2803,7 +2790,7 @@
1938 log_error_write(srv, __FILE__, __LINE__, "ss",
1939 "getsockopt failed:", strerror(errno));
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;
1945 return HANDLER_ERROR;
1946 @@ -2817,7 +2804,7 @@
1947 "socket:", hctx->proc->connection_name);
1950 - hctx->proc->disabled_until = srv->cur_ts + 5;
1951 + hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
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
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);
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;
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
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
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;
1985 hctx->proc->state = PROC_STATE_DIED;
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);
1995 @@ -3032,11 +3019,6 @@
1996 "reconnect attempts:", hctx->reconnects);
1998 return HANDLER_ERROR;
2001 - fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
2003 - return HANDLER_WAIT_FOR_EVENT;
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);
2015 if (fcgi_spawn_connection(srv, p, host, proc)) {
2016 @@ -3288,18 +3270,18 @@
2017 hctx->reconnects < 5) {
2018 fcgi_reconnect(srv, hctx);
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");
2027 return HANDLER_WAIT_FOR_FD;
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");
2037 fcgi_connection_close(srv, hctx);
2039 @@ -3311,10 +3293,10 @@
2040 /* response might have been already started, kill the connection */
2041 fcgi_connection_close(srv, hctx);
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");
2050 connection_set_state(srv, con, CON_STATE_ERROR);
2052 @@ -3364,9 +3346,9 @@
2053 * even if the FCGI_FIN packet is not received yet
2056 - log_error_write(srv, __FILE__, __LINE__, "sbsbsd",
2057 + log_error_write(srv, __FILE__, __LINE__, "sBSbsbsd",
2058 "error: unexpected close of fastcgi connection for",
2060 + con->uri.path, "?", con->uri.query,
2061 "(no fastcgi process on socket:", proc->connection_name, "?)",
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];
2070 - extension = p->conf.exts->exts[k];
2071 + if (ext->key->used == 0) continue;
2073 - if (extension->key->used == 0) continue;
2074 + ct_len = ext->key->used - 1;
2076 - ct_len = extension->key->used - 1;
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)) {
2086 - } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len))) {
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" */
2094 /* extension doesn't match */
2095 - if (k == p->conf.exts->used) {
2096 + if (NULL == extension) {
2097 return HANDLER_GO_ON;
2100 @@ -3535,8 +3519,8 @@
2101 if (!extension->note_is_sent) {
2102 extension->note_is_sent = 1;
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,
2111 @@ -3727,107 +3711,12 @@
2112 for (n = 0; n < ex->used; n++) {
2115 - unsigned long sum_load = 0;
2116 fcgi_extension_host *host;
2118 host = ex->hosts[n];
2120 fcgi_restart_dead_procs(srv, p, host);
2122 - for (proc = host->first; proc; proc = proc->next) {
2123 - sum_load += proc->load;
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");
2135 - for (proc = host->unused_procs; proc && proc->pid != 0; proc = proc->next);
2138 - if (proc == host->unused_procs) host->unused_procs = proc->next;
2140 - if (proc->next) proc->next->prev = NULL;
2144 - proc = fastcgi_process_init();
2145 - proc->id = host->max_id++;
2148 - host->num_procs++;
2150 - if (buffer_is_empty(host->unixsocket)) {
2151 - proc->port = host->port + proc->id;
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);
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;
2164 - proc->prev = NULL;
2165 - proc->next = host->first;
2166 - if (host->first) {
2167 - host->first->prev = proc;
2169 - host->first = proc;
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;
2177 - if (srv->cur_ts - proc->last_used > host->idle_timeout) {
2178 - /* a proc is idling for a long time now,
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);
2189 - if (proc->next) proc->next->prev = proc->prev;
2190 - if (proc->prev) proc->prev->next = proc->next;
2192 - if (proc->prev == NULL) host->first = proc->next;
2194 - proc->prev = NULL;
2195 - proc->next = host->unused_procs;
2197 - if (host->unused_procs) host->unused_procs->prev = proc;
2198 - host->unused_procs = proc;
2200 - kill(proc->pid, SIGTERM);
2202 - proc->state = PROC_STATE_KILLED;
2204 - log_error_write(srv, __FILE__, __LINE__, "ssbsd",
2206 - "socket:", proc->connection_name,
2207 - "pid", proc->pid);
2209 - host->num_procs--;
2211 - /* proc is now in unused, let the next second handle the next process */
2216 for (proc = host->unused_procs; proc; proc = proc->next) {
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)
2224 if (poll_r & POLLNVAL) r |= FDEVENT_NVAL;
2225 if (poll_r & POLLPRI) r |= FDEVENT_PRI;
2227 - return ev->pollfds[ndx].revents;
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)
2239 /* we should be protected by max-fds, but you never know */
2240 - assert(fd < FD_SETSIZE);
2241 + assert(fd < ((int)FD_SETSIZE));
2243 if (events & FDEVENT_IN) {
2244 FD_SET(fd, &(ev->select_set_read));
2245 Index: src/CMakeLists.txt
2246 ===================================================================
2248 ===================================================================
2249 --- src/server.c (.../tags/lighttpd-1.4.23) (revision 2620)
2250 +++ src/server.c (.../branches/lighttpd-1.4.x) (revision 2620)
2252 CLEAN(cond_check_buf);
2254 CLEAN(srvconf.errorlog_file);
2255 + CLEAN(srvconf.breakagelog_file);
2256 CLEAN(srvconf.groupname);
2257 CLEAN(srvconf.username);
2258 CLEAN(srvconf.changeroot);
2260 srv->srvconf.reject_expect_100_with_417 = 1;
2263 - srv->errorlog_fd = -1;
2264 - srv->errorlog_mode = ERRORLOG_STDERR;
2265 + srv->errorlog_fd = STDERR_FILENO;
2266 + srv->errorlog_mode = ERRORLOG_FD;
2268 srv->split_vals = array_init();
2271 CLEAN(cond_check_buf);
2273 CLEAN(srvconf.errorlog_file);
2274 + CLEAN(srvconf.breakagelog_file);
2275 CLEAN(srvconf.groupname);
2276 CLEAN(srvconf.username);
2277 CLEAN(srvconf.changeroot);
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;
2285 srv->max_fds = rlim.rlim_cur;
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.");
2297 * Change group before chroot, when we have access
2300 - if (srv->srvconf.groupname->used) {
2301 + if (NULL != grp) {
2302 setgid(grp->gr_gid);
2304 if (srv->srvconf.username->used) {
2308 /* drop root privs */
2309 - if (srv->srvconf.username->used) {
2310 + if (NULL != pwd) {
2311 setuid(pwd->pw_uid);
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;
2321 srv->max_fds = rlim.rlim_cur;
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)
2339 if (NULL != (du = array_get_element(ca, option))) {
2340 - data_array *da = (data_array *)du;
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 @@
2352 static int magnet_reqhdr_get(lua_State *L) {
2357 const char *key = luaL_checkstring(L, 2);
2359 - lua_pushstring(L, "lighty.srv");
2360 - lua_gettable(L, LUA_REGISTRYINDEX);
2361 - srv = lua_touserdata(L, -1);
2364 lua_pushstring(L, "lighty.con");
2365 lua_gettable(L, LUA_REGISTRYINDEX);
2366 con = lua_touserdata(L, -1);
2368 ===================================================================
2369 --- src/log.c (.../tags/lighttpd-1.4.23) (revision 2620)
2370 +++ src/log.c (.../branches/lighttpd-1.4.x) (revision 2620)
2372 /* create write pipe and spawn process */
2377 if (pipe(to_log_fds)) {
2378 log_error_write(srv, __FILE__, __LINE__, "ss", "pipe failed: ", strerror(errno));
2383 - switch (pid = fork()) {
2387 close(STDIN_FILENO);
2388 @@ -150,14 +149,14 @@
2391 int log_error_open(server *srv) {
2392 - int close_stderr = 1;
2394 #ifdef HAVE_SYSLOG_H
2395 /* perhaps someone wants to use syslog() */
2396 openlog("lighttpd", LOG_CONS | LOG_PID, LOG_DAEMON);
2398 - srv->errorlog_mode = ERRORLOG_STDERR;
2400 + srv->errorlog_mode = ERRORLOG_FD;
2401 + srv->errorlog_fd = STDERR_FILENO;
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 @@
2408 log_error_write(srv, __FILE__, __LINE__, "s", "server started");
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;
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
2421 + srv->errorlog_fd = -1;
2424 - /* move stderr to /dev/null */
2425 - if (close_stderr) openDevNull(STDERR_FILENO);
2426 + if (!buffer_is_empty(srv->srvconf.breakagelog_file)) {
2428 + const char *logfile = srv->srvconf.breakagelog_file->ptr;
2430 + if (srv->errorlog_mode == ERRORLOG_FD) {
2431 + srv->errorlog_fd = dup(STDERR_FILENO);
2433 + fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC);
2437 + if (-1 == (breakage_fd = open_logfile_or_pipe(srv, logfile))) {
2441 + if (STDERR_FILENO != breakage_fd) {
2442 + dup2(breakage_fd, STDERR_FILENO);
2443 + close(breakage_fd);
2445 + } else if (!srv->srvconf.dont_daemonize) {
2446 + /* move stderr to /dev/null */
2447 + openDevNull(STDERR_FILENO);
2452 @@ -235,15 +250,19 @@
2453 switch(srv->errorlog_mode) {
2456 - close(srv->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;
2465 case ERRORLOG_SYSLOG:
2466 #ifdef HAVE_SYSLOG_H
2470 - case ERRORLOG_STDERR:
2476 switch(srv->errorlog_mode) {
2479 - case ERRORLOG_STDERR:
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) {
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);
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);
2497 case ERRORLOG_SYSLOG:
2498 syslog(LOG_ERR, "%s", srv->errorlog_buf->ptr);
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 @@
2507 proc_read_fd_to_buffer(proc.err.fd, err);
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");
2517 pipe_close(&proc.err);
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)
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"
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)
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"
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)
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"
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)
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"
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)
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"
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)
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"
2593 server.force-lowercase-filenames = "enable"
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)
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"
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)
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"
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)
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"
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)
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"
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)
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"
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)
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"
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)
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"
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)
2687 + my $timeout = 5*10; # 5 secs, select waits 0.1 s
2689 while (0 == $self->listening_on($port)) {
2690 select(undef, undef, undef, 0.1);
2693 # the process is gone, we failed
2694 if (0 != waitpid($child, WNOHANG)) {
2697 + if (0 >= $timeout) {
2698 + diag("Timeout while trying to connect; killing child");
2699 + kill('TERM', $child);
2706 ===================================================================
2707 --- configure.ac (.../tags/lighttpd-1.4.23) (revision 2620)
2708 +++ configure.ac (.../branches/lighttpd-1.4.x) (revision 2620)
2711 # Process this file with autoconf to produce a configure script.
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])
2721 @@ -417,12 +418,18 @@
2722 AC_DEFINE([HAVE_LUA], [1], [liblua])
2723 AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
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])
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])
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])
2743 AC_SUBST(LUA_CFLAGS)
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)
2753 ( "host" => <string> ,
2754 "port" => <integer> ,
2755 - "socket" => <string>, # either socket
2757 - "bin-path" => <string>, # OPTIONAL
2758 - "bin-environment" => <array>, # OPTIONAL
2759 - "bin-copy-environment" => <array>, # OPTIONAL
2760 + "socket" => <string>, # either socket
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
2780 + "allow-x-send-file" => <boolean>, # optional
2781 + "kill-signal" => <integer>, # OPTIONAL
2782 + "fix-root-scriptname" => <boolean>,
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
2815 :"allow-x-send-file": controls if X-LIGHTTPD-send-file headers
2817 + :"fix-root-scriptname": fix broken path-info split for "/" extension ("prefix")
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
2826 - :"idle-timeout": number of seconds before a unused process
2828 :"bin-environment": put an entry into the environment of
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
2840 @@ -171,11 +166,11 @@
2841 fastcgi.server = ( ".php" =>
2842 (( "host" => "127.0.0.1",
2844 - "bin-path" => "/usr/local/bin/php"
2845 + "bin-path" => "/usr/local/bin/php"
2848 (( "host" => "127.0.0.1",
2854 @@ -183,10 +178,10 @@
2856 fastcgi.server = ( "/remote_scripts/" =>
2857 (( "host" => "192.168.0.3",
2860 "check-local" => "disable",
2861 "docroot" => "/" # remote server may use
2862 - # it's own docroot
2863 + # it's own docroot
2869 fastcgi.server = ( "/remote_scripts/" =>
2870 (( "host" => "10.0.0.2",
2873 "docroot" => "/path_to_private_docs",
2874 "mode" => "authorizer"
2876 @@ -318,10 +313,10 @@
2877 $ PHP_FCGI_CHILDREN=384 ./lighttpd -f ./lighttpd.conf
2879 fastcgi.server = ( ".php" =>
2880 - (( "socket" => "/tmp/php.socket",
2881 + (( "socket" => "/tmp/php.socket",
2882 "bin-path" => "/usr/local/bin/php",
2886 "max-load-per-proc" => 4,
2887 "idle-timeout" => 20
2890 "PHP_FCGI_CHILDREN" => "16",
2891 "PHP_FCGI_MAX_REQUESTS" => "10000" ),
2892 "bin-copy-environment" => (
2893 - "PATH", "SHELL", "USER" )
2894 + "PATH", "SHELL", "USER" )
2899 ===================================================================
2901 ===================================================================
2902 --- Makefile.am (.../tags/lighttpd-1.4.23) (revision 2620)
2903 +++ Makefile.am (.../branches/lighttpd-1.4.x) (revision 2620)
2906 EXTRA_DIST=autogen.sh SConstruct
2908 +ACLOCAL_AMFLAGS = -I m4
2910 distcleancheck_listfiles = find -type f -exec sh -c 'test -f $(srcdir)/{} || echo {}' ';'
2912 ===================================================================
2913 --- autogen.sh (.../tags/lighttpd-1.4.23) (revision 2620)
2914 +++ autogen.sh (.../branches/lighttpd-1.4.x) (revision 2620)
2917 # Run this to generate all the initial makefiles, etc.
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"
2935 - echo "$ARGV0: running \`$@'"
2937 + echo "$ARGV0: running \`$@' $ARGS"
2941 +## jump out if one of the programs returns 'false'
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
2953 + echo "libtoolize 1.5.x wasn't found, exiting"; exit 0
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
2963 + elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then
2966 + echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0
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
2978 + echo "automake 1.9.x wasn't found, exiting"; exit 0
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
2992 + echo "autoconf 2.59+ wasn't found, exiting"; exit 0
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
3004 + echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0
3009 run $LIBTOOLIZE $LIBTOOLIZE_FLAGS
3010 -run $ACLOCAL $ACLOCAL_FLAGS
3011 +run $ACLOCAL $ACLOCAL_FLAGS -I m4
3013 run $AUTOMAKE $AUTOMAKE_FLAGS
3015 -echo "Now type './configure ...' and 'make' to compile."
3017 +if test "$ARGS" = "" ; then
3018 + echo "Now type './configure ...' and 'make' to compile."
3021 ===================================================================
3022 --- NEWS (.../tags/lighttpd-1.4.23) (revision 2620)
3023 +++ NEWS (.../branches/lighttpd-1.4.x) (revision 2620)
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)
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 ===================================================================