2 ===================================================================
4 ===================================================================
6 ===================================================================
7 Index: src/configfile-glue.c
8 ===================================================================
9 --- src/configfile-glue.c (.../tags/lighttpd-1.4.23)
10 +++ src/configfile-glue.c (.../branches/lighttpd-1.4.x)
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)
64 +++ src/mod_cgi.c (.../branches/lighttpd-1.4.x)
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)
143 +++ src/network_write.c (.../branches/lighttpd-1.4.x)
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)
255 +++ src/mod_secure_download.c (.../branches/lighttpd-1.4.x)
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)
288 +++ src/base.h (.../branches/lighttpd-1.4.x)
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)
335 +++ src/mod_rewrite.c (.../branches/lighttpd-1.4.x)
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)
377 +++ src/connections.c (.../branches/lighttpd-1.4.x)
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)
420 +++ src/network.c (.../branches/lighttpd-1.4.x)
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)
697 +++ src/configfile.c (.../branches/lighttpd-1.4.x)
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)
771 +++ src/mod_evhost.c (.../branches/lighttpd-1.4.x)
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)
797 +++ src/splaytree.c (.../branches/lighttpd-1.4.x)
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)
815 +++ src/lemon.c (.../branches/lighttpd-1.4.x)
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)
901 +++ src/mod_scgi.c (.../branches/lighttpd-1.4.x)
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)
1062 +++ src/mod_mysql_vhost.c (.../branches/lighttpd-1.4.x)
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)
1143 +++ src/request.c (.../branches/lighttpd-1.4.x)
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)
1175 +++ src/network_backends.h (.../branches/lighttpd-1.4.x)
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)
1191 +++ src/mod_rrdtool.c (.../branches/lighttpd-1.4.x)
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)
1216 +++ src/stat_cache.c (.../branches/lighttpd-1.4.x)
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/response.h
1234 ===================================================================
1235 --- src/response.h (.../tags/lighttpd-1.4.23)
1236 +++ src/response.h (.../branches/lighttpd-1.4.x)
1239 int response_header_insert(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen);
1240 int response_header_overwrite(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen);
1241 +int response_header_append(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen);
1243 handler_t http_response_prepare(server *srv, connection *con);
1244 int http_response_redirect_to_directory(server *srv, connection *con);
1245 Index: src/mod_proxy.c
1246 ===================================================================
1247 --- src/mod_proxy.c (.../tags/lighttpd-1.4.23)
1248 +++ src/mod_proxy.c (.../branches/lighttpd-1.4.x)
1249 @@ -756,12 +756,15 @@
1251 switch(hctx->state) {
1252 case PROXY_STATE_INIT:
1253 +#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
1254 if (strstr(host->host->ptr,":")) {
1255 if (-1 == (hctx->fd = socket(AF_INET6, SOCK_STREAM, 0))) {
1256 log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
1257 return HANDLER_ERROR;
1263 if (-1 == (hctx->fd = socket(AF_INET, SOCK_STREAM, 0))) {
1264 log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed: ", strerror(errno));
1265 return HANDLER_ERROR;
1266 @@ -842,17 +845,14 @@
1268 chunkqueue_remove_finished_chunks(hctx->wb);
1271 - if (errno != EAGAIN &&
1273 - log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed:", strerror(errno), errno);
1274 + if (-1 == ret) { /* error on our side */
1275 + log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed:", strerror(errno), errno);
1277 - return HANDLER_ERROR;
1279 - fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
1280 + return HANDLER_WAIT_FOR_EVENT;
1281 + } else if (-2 == ret) { /* remote close */
1282 + log_error_write(srv, __FILE__, __LINE__, "ssd", "write failed, remote connection close:", strerror(errno), errno);
1284 - return HANDLER_WAIT_FOR_EVENT;
1286 + return HANDLER_WAIT_FOR_EVENT;
1289 if (hctx->wb->bytes_out == hctx->wb->bytes_in) {
1290 @@ -1107,19 +1107,20 @@
1292 /* check if extension matches */
1293 for (k = 0; k < p->conf.extensions->used; k++) {
1294 + data_array *ext = NULL;
1297 - extension = (data_array *)p->conf.extensions->data[k];
1298 + ext = (data_array *)p->conf.extensions->data[k];
1300 - if (extension->key->used == 0) continue;
1301 + if (ext->key->used == 0) continue;
1303 - ct_len = extension->key->used - 1;
1304 + ct_len = ext->key->used - 1;
1306 if (s_len < ct_len) continue;
1308 /* check extension in the form "/proxy_pattern" */
1309 - if (*(extension->key->ptr) == '/') {
1310 - if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
1311 + if (*(ext->key->ptr) == '/') {
1312 + if (strncmp(fn->ptr, ext->key->ptr, ct_len) == 0) {
1313 if (s_len > ct_len + 1) {
1316 @@ -1127,15 +1128,17 @@
1317 path_info_offset = pi_offset - fn->ptr;
1323 - } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
1324 + } else if (0 == strncmp(fn->ptr + s_len - ct_len, ext->key->ptr, ct_len)) {
1325 /* check extension in the form ".fcg" */
1331 - if (k == p->conf.extensions->used) {
1332 + if (NULL == extension) {
1333 return HANDLER_GO_ON;
1336 Index: src/Makefile.am
1337 ===================================================================
1338 --- src/Makefile.am (.../tags/lighttpd-1.4.23)
1339 +++ src/Makefile.am (.../branches/lighttpd-1.4.x)
1342 @test -f versionstamp.h || touch versionstamp.h; \
1344 - if test -x "`which svnversion`"; then \
1345 - REVISION="$$(LANG=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)"; \
1346 + if test -d "$(top_srcdir)/.svn" -a -x "`which svnversion`"; then \
1347 + REVISION="$$(LANG= LC_ALL=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)"; \
1348 if test "$$REVISION" = "exported"; then \
1352 if test -z "$$REVISION" -a -x "`which git`"; then \
1353 - REVISION="$$(cd "$(top_srcdir)"; LANG=C git describe --always 2>/dev/null || echo)"; \
1354 + REVISION="$$(cd "$(top_srcdir)"; LANG= LC_ALL=C git describe --always 2>/dev/null || echo)"; \
1356 if test -n "$$REVISION"; then \
1357 echo "#define REPO_VERSION \"-devel-$$REVISION\"" > versionstamp.h.tmp; \
1358 Index: src/mod_expire.c
1359 ===================================================================
1360 --- src/mod_expire.c (.../tags/lighttpd-1.4.23)
1361 +++ src/mod_expire.c (.../branches/lighttpd-1.4.x)
1363 buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
1364 buffer_append_long(p->expire_tstmp, expires - srv->cur_ts); /* as expires >= srv->cur_ts the difference is >= 0 */
1366 - response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
1367 + response_header_append(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
1369 return HANDLER_GO_ON;
1371 Index: src/http_auth.c
1372 ===================================================================
1373 --- src/http_auth.c (.../tags/lighttpd-1.4.23)
1374 +++ src/http_auth.c (.../branches/lighttpd-1.4.x)
1375 @@ -918,15 +918,15 @@
1388 + char *username = NULL;
1389 + char *realm = NULL;
1390 + char *nonce = NULL;
1392 + char *algorithm = NULL;
1394 + char *cnonce = NULL;
1396 + char *respons = NULL;
1399 const char *m = NULL;
1400 @@ -967,15 +967,9 @@
1401 dkv[6].ptr = &cnonce;
1403 dkv[8].ptr = &respons;
1404 - dkv[9].ptr = NULL;
1408 - for (i = 0; dkv[i].key; i++) {
1409 - *(dkv[i].ptr) = NULL;
1413 if (p->conf.auth_backend != AUTH_BACKEND_HTDIGEST &&
1414 p->conf.auth_backend != AUTH_BACKEND_PLAIN) {
1415 log_error_write(srv, __FILE__, __LINE__, "s",
1416 Index: src/mod_redirect.c
1417 ===================================================================
1418 --- src/mod_redirect.c (.../tags/lighttpd-1.4.23)
1419 +++ src/mod_redirect.c (.../branches/lighttpd-1.4.x)
1424 - size_t start, end;
1429 @@ -213,17 +213,15 @@
1431 buffer_reset(p->location);
1433 - start = 0; end = pattern_len;
1435 for (k = 0; k < pattern_len; k++) {
1436 if (pattern[k] == '$' || pattern[k] == '%') {
1439 size_t num = pattern[k + 1] - '0';
1442 + buffer_append_string_len(p->location, pattern + start, k - start);
1444 - buffer_append_string_len(p->location, pattern + start, end - start);
1446 if (!isdigit((unsigned char)pattern[k + 1])) {
1447 /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */
1448 buffer_append_string_len(p->location, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2);
1449 Index: src/mod_webdav.c
1450 ===================================================================
1451 --- src/mod_webdav.c (.../tags/lighttpd-1.4.23)
1452 +++ src/mod_webdav.c (.../branches/lighttpd-1.4.x)
1453 @@ -1096,6 +1096,7 @@
1458 static int webdav_lockdiscovery(server *srv, connection *con,
1459 buffer *locktoken, const char *lockscope, const char *locktype, int depth) {
1461 @@ -1150,6 +1151,8 @@
1468 * check if resource is having the right locks to access to resource
1470 Index: src/configparser.y
1471 ===================================================================
1472 --- src/configparser.y (.../tags/lighttpd-1.4.23)
1473 +++ src/configparser.y (.../branches/lighttpd-1.4.x)
1476 return (data_unset *)ds;
1478 - fprintf(stderr, "data type mismatch, cannot be merge\n");
1479 + fprintf(stderr, "data type mismatch, cannot merge\n");
1484 du = configparser_merge_data(du, B);
1490 buffer_copy_string_buffer(du->key, A);
1492 case CONFIG_COND_MATCH: {
1496 + int erroff, captures;
1498 if (NULL == (dc->regex =
1499 pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) {
1500 @@ -487,6 +486,14 @@
1501 fprintf(stderr, "studying regex failed: %s -> %s\n",
1502 rvalue->ptr, errptr);
1504 + } else if (0 != (pcre_fullinfo(dc->regex, dc->regex_study, PCRE_INFO_CAPTURECOUNT, &captures))) {
1505 + fprintf(stderr, "getting capture count for regex failed: %s\n",
1508 + } else if (captures > 9) {
1509 + fprintf(stderr, "Too many captures in regex, use (?:...) instead of (...): %s\n",
1513 dc->string = buffer_init_buffer(rvalue);
1515 Index: src/mod_status.c
1516 ===================================================================
1517 --- src/mod_status.c (.../tags/lighttpd-1.4.23)
1518 +++ src/mod_status.c (.../branches/lighttpd-1.4.x)
1521 buffer_append_string_len(b, CONST_STR_LEN(
1522 "<hr />\n<pre><b>legend</b>\n"
1523 - ". = connect, C = close, E = hard error\n"
1524 + ". = connect, C = close, E = hard error, k = keep-alive\n"
1525 "r = read, R = read-POST, W = write, h = handle-request\n"
1526 "q = request-start, Q = request-end\n"
1527 "s = response-start, S = response-end\n"));
1528 @@ -449,8 +449,14 @@
1530 for (j = 0; j < srv->conns->used; j++) {
1531 connection *c = srv->conns->ptr[j];
1532 - const char *state = connection_get_short_state(c->state);
1533 + const char *state;
1535 + if (CON_STATE_READ == c->state && c->request.orig_uri->used > 0) {
1538 + state = connection_get_short_state(c->state);
1541 buffer_append_string_len(b, state, 1);
1543 if (((j + 1) % 50) == 0) {
1544 @@ -497,7 +503,11 @@
1546 buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">"));
1548 - buffer_append_string(b, connection_get_state(c->state));
1549 + if (CON_STATE_READ == c->state && c->request.orig_uri->used > 0) {
1550 + buffer_append_string_len(b, CONST_STR_LEN("keep-alive"));
1552 + buffer_append_string(b, connection_get_state(c->state));
1555 buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">"));
1557 @@ -611,10 +621,10 @@
1560 static handler_t mod_status_handle_server_statistics(server *srv, connection *con, void *p_d) {
1561 - plugin_data *p = p_d;
1562 - buffer *b = p->module_list;
1565 array *st = srv->status;
1568 if (0 == st->used) {
1569 /* we have nothing to send */
1570 Index: src/mod_ssi.c
1571 ===================================================================
1572 --- src/mod_ssi.c (.../tags/lighttpd-1.4.23)
1573 +++ src/mod_ssi.c (.../branches/lighttpd-1.4.x)
1578 - int var = 0, enc = 0;
1580 + /* int enc = 0; */
1581 const char *var_val = NULL;
1582 stat_cache_entry *sce = NULL;
1585 { NULL, SSI_ECHO_UNSET }
1591 enum { SSI_ENC_UNSET, SSI_ENC_URL, SSI_ENC_NONE, SSI_ENC_ENTITY } type;
1594 { NULL, SSI_ENC_UNSET }
1598 for (i = 2; i < n; i += 2) {
1599 if (0 == strcmp(l[i], "var")) {
1603 } else if (0 == strcmp(l[i], "encoding")) {
1607 for (j = 0; encvars[j].var; j++) {
1614 log_error_write(srv, __FILE__, __LINE__, "sss",
1615 "ssi: unknow attribute for ",
1616 Index: src/mod_auth.c
1617 ===================================================================
1618 --- src/mod_auth.c (.../tags/lighttpd-1.4.23)
1619 +++ src/mod_auth.c (.../branches/lighttpd-1.4.x)
1622 if (method == NULL) {
1623 log_error_write(srv, __FILE__, __LINE__, "ss",
1624 - "the require field is missing in:",
1625 + "the method field is missing in:",
1626 "auth.require = ( \"...\" => ( ..., \"method\" => \"...\" ) )");
1627 return HANDLER_ERROR;
1631 if (realm == NULL) {
1632 log_error_write(srv, __FILE__, __LINE__, "ss",
1633 - "the require field is missing in:",
1634 + "the realm field is missing in:",
1635 "auth.require = ( \"...\" => ( ..., \"realm\" => \"...\" ) )");
1636 return HANDLER_ERROR;
1638 Index: src/mod_cml_lua.c
1639 ===================================================================
1640 --- src/mod_cml_lua.c (.../tags/lighttpd-1.4.23)
1641 +++ src/mod_cml_lua.c (.../branches/lighttpd-1.4.x)
1646 +#include <string.h>
1648 #include "mod_cml.h"
1649 #include "mod_cml_funcs.h"
1650 Index: src/http-header-glue.c
1651 ===================================================================
1652 --- src/http-header-glue.c (.../tags/lighttpd-1.4.23)
1653 +++ src/http-header-glue.c (.../branches/lighttpd-1.4.x)
1654 @@ -104,6 +104,21 @@
1655 return response_header_insert(srv, con, key, keylen, value, vallen);
1658 +int response_header_append(server *srv, connection *con, const char *key, size_t keylen, const char *value, size_t vallen) {
1663 + /* if there already is a key by this name append the value */
1664 + if (NULL != (ds = (data_string *)array_get_element(con->response.headers, key))) {
1665 + buffer_append_string_len(ds->value, CONST_STR_LEN(", "));
1666 + buffer_append_string_len(ds->value, value, vallen);
1670 + return response_header_insert(srv, con, key, keylen, value, vallen);
1673 int http_response_redirect_to_directory(server *srv, connection *con) {
1679 if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) {
1680 - con->http_status = 304;
1681 + if ('\0' == mtime->ptr[used_len]) con->http_status = 304;
1682 return HANDLER_FINISHED;
1684 char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
1685 @@ -281,15 +296,16 @@
1686 strncpy(buf, con->request.http_if_modified_since, used_len);
1687 buf[used_len] = '\0';
1690 if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
1691 con->http_status = 412;
1693 return HANDLER_FINISHED;
1696 t_header = mktime(&tm);
1698 strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
1700 t_file = mktime(&tm);
1702 if (t_file > t_header) return HANDLER_GO_ON;
1706 if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) {
1707 - con->http_status = 304;
1708 + if ('\0' == mtime->ptr[used_len]) con->http_status = 304;
1709 return HANDLER_FINISHED;
1711 char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
1712 @@ -331,18 +347,17 @@
1713 strncpy(buf, con->request.http_if_modified_since, used_len);
1714 buf[used_len] = '\0';
1717 if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
1719 * parsing failed, let's get out of here
1721 - log_error_write(srv, __FILE__, __LINE__, "ss",
1722 - "strptime() failed on", buf);
1723 return HANDLER_GO_ON;
1726 t_header = mktime(&tm);
1728 strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
1730 t_file = mktime(&tm);
1732 if (t_file > t_header) return HANDLER_GO_ON;
1733 Index: src/mod_setenv.c
1734 ===================================================================
1735 --- src/mod_setenv.c (.../tags/lighttpd-1.4.23)
1736 +++ src/mod_setenv.c (.../branches/lighttpd-1.4.x)
1738 return HANDLER_GO_ON;
1741 -REQUESTDONE_FUNC(mod_setenv_reset) {
1742 +CONNECTION_FUNC(mod_setenv_reset) {
1743 plugin_data *p = p_d;
1747 p->set_defaults = mod_setenv_set_defaults;
1748 p->cleanup = mod_setenv_free;
1750 - p->handle_request_done = mod_setenv_reset;
1751 + p->connection_reset = mod_setenv_reset;
1755 Index: src/mod_fastcgi.c
1756 ===================================================================
1757 --- src/mod_fastcgi.c (.../tags/lighttpd-1.4.23)
1758 +++ src/mod_fastcgi.c (.../branches/lighttpd-1.4.x)
1759 @@ -122,24 +122,11 @@
1763 - unsigned short min_procs;
1764 unsigned short max_procs;
1765 size_t num_procs; /* how many procs are started */
1766 size_t active_procs; /* how many of them are really running */
1768 - unsigned short max_load_per_proc;
1771 - * kick the process from the list if it was not
1772 - * used for idle_timeout until min_procs is
1773 - * reached. this helps to get the processlist
1774 - * small again we had a small peak load.
1778 - unsigned short idle_timeout;
1781 * time after a disabled remote connection is tried to be re-enabled
1784 @@ -384,6 +371,21 @@
1785 /* ok, we need a prototype */
1786 static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents);
1788 +static void reset_signals(void) {
1790 + signal(SIGTTOU, SIG_DFL);
1793 + signal(SIGTTIN, SIG_DFL);
1796 + signal(SIGTSTP, SIG_DFL);
1798 + signal(SIGHUP, SIG_DFL);
1799 + signal(SIGPIPE, SIG_DFL);
1800 + signal(SIGUSR1, SIG_DFL);
1803 static void fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) {
1804 buffer_copy_string_len(b, CONST_STR_LEN("fastcgi.backend."));
1805 buffer_append_string_buffer(b, host->id);
1810 - openDevNull(STDERR_FILENO);
1812 /* we don't need the client socket */
1813 for (i = 3; i < 256; i++) {
1815 @@ -1054,6 +1054,7 @@
1822 execve(arg.ptr[0], arg.ptr, env.ptr);
1823 @@ -1235,20 +1236,17 @@
1825 { "check-local", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 5 */
1826 { "port", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 6 */
1827 - { "min-procs-not-working", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 7 this is broken for now */
1828 - { "max-procs", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
1829 - { "max-load-per-proc", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 9 */
1830 - { "idle-timeout", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
1831 - { "disable-time", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 11 */
1832 + { "max-procs", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 7 */
1833 + { "disable-time", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
1835 - { "bin-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 12 */
1836 - { "bin-copy-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 13 */
1837 + { "bin-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 9 */
1838 + { "bin-copy-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 10 */
1840 - { "broken-scriptfilename", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 14 */
1841 - { "allow-x-send-file", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 15 */
1842 - { "strip-request-uri", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 16 */
1843 - { "kill-signal", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 17 */
1844 - { "fix-root-scriptname", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 18 */
1845 + { "broken-scriptfilename", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 11 */
1846 + { "allow-x-send-file", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 12 */
1847 + { "strip-request-uri", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 13 */
1848 + { "kill-signal", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 14 */
1849 + { "fix-root-scriptname", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 15 */
1851 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
1853 @@ -1267,12 +1265,9 @@
1854 buffer_copy_string_buffer(host->id, da_host->key);
1856 host->check_local = 1;
1857 - host->min_procs = 4;
1858 host->max_procs = 4;
1859 - host->max_load_per_proc = 1;
1860 - host->idle_timeout = 60;
1861 host->mode = FCGI_RESPONDER;
1862 - host->disable_time = 60;
1863 + host->disable_time = 1;
1864 host->break_scriptfilename_for_php = 0;
1865 host->allow_xsendfile = 0; /* handle X-LIGHTTPD-send-file */
1866 host->kill_signal = SIGTERM;
1867 @@ -1286,19 +1281,16 @@
1869 fcv[5].destination = &(host->check_local);
1870 fcv[6].destination = &(host->port);
1871 - fcv[7].destination = &(host->min_procs);
1872 - fcv[8].destination = &(host->max_procs);
1873 - fcv[9].destination = &(host->max_load_per_proc);
1874 - fcv[10].destination = &(host->idle_timeout);
1875 - fcv[11].destination = &(host->disable_time);
1876 + fcv[7].destination = &(host->max_procs);
1877 + fcv[8].destination = &(host->disable_time);
1879 - fcv[12].destination = host->bin_env;
1880 - fcv[13].destination = host->bin_env_copy;
1881 - fcv[14].destination = &(host->break_scriptfilename_for_php);
1882 - fcv[15].destination = &(host->allow_xsendfile);
1883 - fcv[16].destination = host->strip_request_uri;
1884 - fcv[17].destination = &(host->kill_signal);
1885 - fcv[18].destination = &(host->fix_root_path_name);
1886 + fcv[9].destination = host->bin_env;
1887 + fcv[10].destination = host->bin_env_copy;
1888 + fcv[11].destination = &(host->break_scriptfilename_for_php);
1889 + fcv[12].destination = &(host->allow_xsendfile);
1890 + fcv[13].destination = host->strip_request_uri;
1891 + fcv[14].destination = &(host->kill_signal);
1892 + fcv[15].destination = &(host->fix_root_path_name);
1894 if (0 != config_insert_values_internal(srv, da_host->value, fcv)) {
1895 return HANDLER_ERROR;
1896 @@ -1355,23 +1347,16 @@
1897 /* a local socket + self spawning */
1900 - /* HACK: just to make sure the adaptive spawing is disabled */
1901 - host->min_procs = host->max_procs;
1903 - if (host->min_procs > host->max_procs) host->max_procs = host->min_procs;
1904 - if (host->max_load_per_proc < 1) host->max_load_per_proc = 0;
1907 - log_error_write(srv, __FILE__, __LINE__, "ssbsdsbsdsd",
1908 + log_error_write(srv, __FILE__, __LINE__, "ssbsdsbsd",
1909 "--- fastcgi spawning local",
1910 "\n\tproc:", host->bin_path,
1911 "\n\tport:", host->port,
1912 "\n\tsocket", host->unixsocket,
1913 - "\n\tmin-procs:", host->min_procs,
1914 "\n\tmax-procs:", host->max_procs);
1917 - for (pno = 0; pno < host->min_procs; pno++) {
1918 + for (pno = 0; pno < host->max_procs; pno++) {
1921 proc = fastcgi_process_init();
1922 @@ -1391,7 +1376,7 @@
1923 "--- fastcgi spawning",
1924 "\n\tport:", host->port,
1925 "\n\tsocket", host->unixsocket,
1926 - "\n\tcurrent:", pno, "/", host->min_procs);
1927 + "\n\tcurrent:", pno, "/", host->max_procs);
1930 if (fcgi_spawn_connection(srv, p, host, proc)) {
1931 @@ -1426,7 +1411,6 @@
1935 - host->min_procs = 1;
1936 host->max_procs = 1;
1939 @@ -2739,7 +2723,7 @@
1940 log_error_write(srv, __FILE__, __LINE__, "ssbsdsd",
1941 "--- fastcgi spawning",
1942 "\n\tsocket", proc->connection_name,
1943 - "\n\tcurrent:", 1, "/", host->min_procs);
1944 + "\n\tcurrent:", 1, "/", host->max_procs);
1947 if (fcgi_spawn_connection(srv, p, host, proc)) {
1948 @@ -2778,8 +2762,11 @@
1949 * - tcp socket (do not check host->host->uses, as it may be not set which means INADDR_LOOPBACK)
1953 - (!host->port && !host->unixsocket->used)) {
1955 + log_error_write(srv, __FILE__, __LINE__, "s", "fatal error: host = NULL");
1956 + return HANDLER_ERROR;
1958 + if ((!host->port && !host->unixsocket->used)) {
1959 log_error_write(srv, __FILE__, __LINE__, "sxddd",
1962 @@ -2787,7 +2774,7 @@
1964 host->unixsocket->used);
1966 - hctx->proc->disabled_until = srv->cur_ts + 10;
1967 + hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1968 hctx->proc->state = PROC_STATE_DIED;
1970 return HANDLER_ERROR;
1971 @@ -2803,7 +2790,7 @@
1972 log_error_write(srv, __FILE__, __LINE__, "ss",
1973 "getsockopt failed:", strerror(errno));
1975 - hctx->proc->disabled_until = srv->cur_ts + 10;
1976 + hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1977 hctx->proc->state = PROC_STATE_DIED;
1979 return HANDLER_ERROR;
1980 @@ -2817,7 +2804,7 @@
1981 "socket:", hctx->proc->connection_name);
1984 - hctx->proc->disabled_until = srv->cur_ts + 5;
1985 + hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
1987 if (hctx->proc->is_local) {
1988 hctx->proc->state = PROC_STATE_DIED_WAIT_FOR_PID;
1989 @@ -2910,13 +2897,13 @@
1990 /* cool down the backend, it is overloaded
1993 - log_error_write(srv, __FILE__, __LINE__, "ssdsd",
1994 - "backend is overloaded; we'll disable it for 2 seconds and send the request to another backend instead:",
1995 + log_error_write(srv, __FILE__, __LINE__, "sdssdsd",
1996 + "backend is overloaded; we'll disable it for", hctx->host->disable_time, "seconds and send the request to another backend instead:",
1997 "reconnects:", hctx->reconnects,
1998 "load:", host->load);
2001 - hctx->proc->disabled_until = srv->cur_ts + 2;
2002 + hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
2003 hctx->proc->state = PROC_STATE_OVERLOADED;
2005 fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc);
2006 @@ -2930,18 +2917,18 @@
2007 * - ECONNREFUSED for tcp-ip sockets
2008 * - ENOENT for unix-domain-sockets
2010 - * for check if the host is back in 5 seconds
2011 + * for check if the host is back in hctx->host->disable_time seconds
2014 - hctx->proc->disabled_until = srv->cur_ts + 5;
2015 + hctx->proc->disabled_until = srv->cur_ts + hctx->host->disable_time;
2016 if (hctx->proc->is_local) {
2017 hctx->proc->state = PROC_STATE_DIED_WAIT_FOR_PID;
2019 hctx->proc->state = PROC_STATE_DIED;
2022 - log_error_write(srv, __FILE__, __LINE__, "ssdsd",
2023 - "backend died; we'll disable it for 5 seconds and send the request to another backend instead:",
2024 + log_error_write(srv, __FILE__, __LINE__, "sdssdsd",
2025 + "backend died; we'll disable it for", hctx->host->disable_time, "seconds and send the request to another backend instead:",
2026 "reconnects:", hctx->reconnects,
2027 "load:", host->load);
2029 @@ -3032,11 +3019,6 @@
2030 "reconnect attempts:", hctx->reconnects);
2032 return HANDLER_ERROR;
2035 - fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_OUT);
2037 - return HANDLER_WAIT_FOR_EVENT;
2039 log_error_write(srv, __FILE__, __LINE__, "ssd",
2040 "write failed:", strerror(errno), errno);
2041 @@ -3266,7 +3248,7 @@
2042 log_error_write(srv, __FILE__, __LINE__, "ssbsdsd",
2043 "--- fastcgi spawning",
2044 "\n\tsocket", proc->connection_name,
2045 - "\n\tcurrent:", 1, "/", host->min_procs);
2046 + "\n\tcurrent:", 1, "/", host->max_procs);
2049 if (fcgi_spawn_connection(srv, p, host, proc)) {
2050 @@ -3288,18 +3270,18 @@
2051 hctx->reconnects < 5) {
2052 fcgi_reconnect(srv, hctx);
2054 - log_error_write(srv, __FILE__, __LINE__, "ssbsbs",
2055 + log_error_write(srv, __FILE__, __LINE__, "ssbsBSBs",
2056 "response not received, request not sent",
2057 "on socket:", proc->connection_name,
2058 - "for", con->uri.path, ", reconnecting");
2059 + "for", con->uri.path, "?", con->uri.query, ", reconnecting");
2061 return HANDLER_WAIT_FOR_FD;
2064 - log_error_write(srv, __FILE__, __LINE__, "sosbsbs",
2065 + log_error_write(srv, __FILE__, __LINE__, "sosbsBSBs",
2066 "response not received, request sent:", hctx->wb->bytes_out,
2067 "on socket:", proc->connection_name,
2068 - "for", con->uri.path, ", closing connection");
2069 + "for", con->uri.path, "?", con->uri.query, ", closing connection");
2071 fcgi_connection_close(srv, hctx);
2073 @@ -3311,10 +3293,10 @@
2074 /* response might have been already started, kill the connection */
2075 fcgi_connection_close(srv, hctx);
2077 - log_error_write(srv, __FILE__, __LINE__, "ssbsbs",
2078 + log_error_write(srv, __FILE__, __LINE__, "ssbsBSBs",
2079 "response already sent out, but backend returned error",
2080 "on socket:", proc->connection_name,
2081 - "for", con->uri.path, ", terminating connection");
2082 + "for", con->uri.path, "?", con->uri.query, ", terminating connection");
2084 connection_set_state(srv, con, CON_STATE_ERROR);
2086 @@ -3364,9 +3346,9 @@
2087 * even if the FCGI_FIN packet is not received yet
2090 - log_error_write(srv, __FILE__, __LINE__, "sbsbsd",
2091 + log_error_write(srv, __FILE__, __LINE__, "sBSbsbsd",
2092 "error: unexpected close of fastcgi connection for",
2094 + con->uri.path, "?", con->uri.query,
2095 "(no fastcgi process on socket:", proc->connection_name, "?)",
2098 @@ -3489,25 +3471,27 @@
2099 /* check if extension matches */
2100 for (k = 0; k < p->conf.exts->used; k++) {
2101 size_t ct_len; /* length of the config entry */
2102 + fcgi_extension *ext = p->conf.exts->exts[k];
2104 - extension = p->conf.exts->exts[k];
2105 + if (ext->key->used == 0) continue;
2107 - if (extension->key->used == 0) continue;
2108 + ct_len = ext->key->used - 1;
2110 - ct_len = extension->key->used - 1;
2112 /* check _url_ in the form "/fcgi_pattern" */
2113 - if (extension->key->ptr[0] == '/') {
2114 + if (ext->key->ptr[0] == '/') {
2115 if ((ct_len <= con->uri.path->used -1) &&
2116 - (strncmp(con->uri.path->ptr, extension->key->ptr, ct_len) == 0))
2117 + (strncmp(con->uri.path->ptr, ext->key->ptr, ct_len) == 0)) {
2120 - } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len))) {
2122 + } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, ext->key->ptr, ct_len))) {
2123 /* check extension in the form ".fcg" */
2128 /* extension doesn't match */
2129 - if (k == p->conf.exts->used) {
2130 + if (NULL == extension) {
2131 return HANDLER_GO_ON;
2134 @@ -3535,8 +3519,8 @@
2135 if (!extension->note_is_sent) {
2136 extension->note_is_sent = 1;
2138 - log_error_write(srv, __FILE__, __LINE__, "sbsbs",
2139 - "all handlers for ", con->uri.path,
2140 + log_error_write(srv, __FILE__, __LINE__, "sBSbsbs",
2141 + "all handlers for", con->uri.path, "?", con->uri.query,
2142 "on", extension->key,
2145 @@ -3727,107 +3711,12 @@
2146 for (n = 0; n < ex->used; n++) {
2149 - unsigned long sum_load = 0;
2150 fcgi_extension_host *host;
2152 host = ex->hosts[n];
2154 fcgi_restart_dead_procs(srv, p, host);
2156 - for (proc = host->first; proc; proc = proc->next) {
2157 - sum_load += proc->load;
2160 - if (host->num_procs &&
2161 - host->num_procs < host->max_procs &&
2162 - (sum_load / host->num_procs) > host->max_load_per_proc) {
2163 - /* overload, spawn new child */
2164 - if (p->conf.debug) {
2165 - log_error_write(srv, __FILE__, __LINE__, "s",
2166 - "overload detected, spawning a new child");
2169 - for (proc = host->unused_procs; proc && proc->pid != 0; proc = proc->next);
2172 - if (proc == host->unused_procs) host->unused_procs = proc->next;
2174 - if (proc->next) proc->next->prev = NULL;
2178 - proc = fastcgi_process_init();
2179 - proc->id = host->max_id++;
2182 - host->num_procs++;
2184 - if (buffer_is_empty(host->unixsocket)) {
2185 - proc->port = host->port + proc->id;
2187 - buffer_copy_string_buffer(proc->unixsocket, host->unixsocket);
2188 - buffer_append_string_len(proc->unixsocket, CONST_STR_LEN("-"));
2189 - buffer_append_long(proc->unixsocket, proc->id);
2192 - if (fcgi_spawn_connection(srv, p, host, proc)) {
2193 - log_error_write(srv, __FILE__, __LINE__, "s",
2194 - "ERROR: spawning fcgi failed.");
2195 - return HANDLER_ERROR;
2198 - proc->prev = NULL;
2199 - proc->next = host->first;
2200 - if (host->first) {
2201 - host->first->prev = proc;
2203 - host->first = proc;
2206 - for (proc = host->first; proc; proc = proc->next) {
2207 - if (proc->load != 0) break;
2208 - if (host->num_procs <= host->min_procs) break;
2209 - if (proc->pid == 0) continue;
2211 - if (srv->cur_ts - proc->last_used > host->idle_timeout) {
2212 - /* a proc is idling for a long time now,
2215 - if (p->conf.debug) {
2216 - log_error_write(srv, __FILE__, __LINE__, "ssbsd",
2217 - "idle-timeout reached; terminating child:",
2218 - "socket:", proc->connection_name,
2219 - "pid", proc->pid);
2223 - if (proc->next) proc->next->prev = proc->prev;
2224 - if (proc->prev) proc->prev->next = proc->next;
2226 - if (proc->prev == NULL) host->first = proc->next;
2228 - proc->prev = NULL;
2229 - proc->next = host->unused_procs;
2231 - if (host->unused_procs) host->unused_procs->prev = proc;
2232 - host->unused_procs = proc;
2234 - kill(proc->pid, SIGTERM);
2236 - proc->state = PROC_STATE_KILLED;
2238 - log_error_write(srv, __FILE__, __LINE__, "ssbsd",
2240 - "socket:", proc->connection_name,
2241 - "pid", proc->pid);
2243 - host->num_procs--;
2245 - /* proc is now in unused, let the next second handle the next process */
2250 for (proc = host->unused_procs; proc; proc = proc->next) {
2253 Index: src/fdevent_poll.c
2254 ===================================================================
2255 --- src/fdevent_poll.c (.../tags/lighttpd-1.4.23)
2256 +++ src/fdevent_poll.c (.../branches/lighttpd-1.4.x)
2258 if (poll_r & POLLNVAL) r |= FDEVENT_NVAL;
2259 if (poll_r & POLLPRI) r |= FDEVENT_PRI;
2261 - return ev->pollfds[ndx].revents;
2265 static int fdevent_poll_event_get_fd(fdevents *ev, size_t ndx) {
2266 Index: src/fdevent_select.c
2267 ===================================================================
2268 --- src/fdevent_select.c (.../tags/lighttpd-1.4.23)
2269 +++ src/fdevent_select.c (.../branches/lighttpd-1.4.x)
2273 /* we should be protected by max-fds, but you never know */
2274 - assert(fd < FD_SETSIZE);
2275 + assert(fd < ((int)FD_SETSIZE));
2277 if (events & FDEVENT_IN) {
2278 FD_SET(fd, &(ev->select_set_read));
2279 Index: src/CMakeLists.txt
2280 ===================================================================
2282 ===================================================================
2283 --- src/server.c (.../tags/lighttpd-1.4.23)
2284 +++ src/server.c (.../branches/lighttpd-1.4.x)
2286 CLEAN(cond_check_buf);
2288 CLEAN(srvconf.errorlog_file);
2289 + CLEAN(srvconf.breakagelog_file);
2290 CLEAN(srvconf.groupname);
2291 CLEAN(srvconf.username);
2292 CLEAN(srvconf.changeroot);
2294 srv->srvconf.reject_expect_100_with_417 = 1;
2297 - srv->errorlog_fd = -1;
2298 - srv->errorlog_mode = ERRORLOG_STDERR;
2299 + srv->errorlog_fd = STDERR_FILENO;
2300 + srv->errorlog_mode = ERRORLOG_FD;
2302 srv->split_vals = array_init();
2305 CLEAN(cond_check_buf);
2307 CLEAN(srvconf.errorlog_file);
2308 + CLEAN(srvconf.breakagelog_file);
2309 CLEAN(srvconf.groupname);
2310 CLEAN(srvconf.username);
2311 CLEAN(srvconf.changeroot);
2315 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2316 - srv->max_fds = rlim.rlim_cur < FD_SETSIZE - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2317 + srv->max_fds = rlim.rlim_cur < ((int)FD_SETSIZE) - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2319 srv->max_fds = rlim.rlim_cur;
2323 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2324 /* don't raise the limit above FD_SET_SIZE */
2325 - if (srv->max_fds > FD_SETSIZE - 200) {
2326 + if (srv->max_fds > ((int)FD_SETSIZE) - 200) {
2327 log_error_write(srv, __FILE__, __LINE__, "sd",
2328 "can't raise max filedescriptors above", FD_SETSIZE - 200,
2329 "if event-handler is 'select'. Use 'poll' or something else or reduce server.max-fds.");
2331 * Change group before chroot, when we have access
2334 - if (srv->srvconf.groupname->used) {
2335 + if (NULL != grp) {
2336 setgid(grp->gr_gid);
2338 if (srv->srvconf.username->used) {
2342 /* drop root privs */
2343 - if (srv->srvconf.username->used) {
2344 + if (NULL != pwd) {
2345 setuid(pwd->pw_uid);
2351 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2352 - srv->max_fds = rlim.rlim_cur < FD_SETSIZE - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2353 + srv->max_fds = rlim.rlim_cur < ((int)FD_SETSIZE) - 200 ? rlim.rlim_cur : FD_SETSIZE - 200;
2355 srv->max_fds = rlim.rlim_cur;
2359 if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
2360 /* don't raise the limit above FD_SET_SIZE */
2361 - if (srv->max_fds > FD_SETSIZE - 200) {
2362 + if (srv->max_fds > ((int)FD_SETSIZE) - 200) {
2363 log_error_write(srv, __FILE__, __LINE__, "sd",
2364 "can't raise max filedescriptors above", FD_SETSIZE - 200,
2365 "if event-handler is 'select'. Use 'poll' or something else or reduce server.max-fds.");
2366 Index: src/mod_dirlisting.c
2367 ===================================================================
2368 --- src/mod_dirlisting.c (.../tags/lighttpd-1.4.23)
2369 +++ src/mod_dirlisting.c (.../branches/lighttpd-1.4.x)
2373 if (NULL != (du = array_get_element(ca, option))) {
2374 - data_array *da = (data_array *)du;
2378 if (du->type != TYPE_ARRAY) {
2379 Index: src/mod_magnet.c
2380 ===================================================================
2381 --- src/mod_magnet.c (.../tags/lighttpd-1.4.23)
2382 +++ src/mod_magnet.c (.../branches/lighttpd-1.4.x)
2383 @@ -283,17 +283,11 @@
2386 static int magnet_reqhdr_get(lua_State *L) {
2391 const char *key = luaL_checkstring(L, 2);
2393 - lua_pushstring(L, "lighty.srv");
2394 - lua_gettable(L, LUA_REGISTRYINDEX);
2395 - srv = lua_touserdata(L, -1);
2398 lua_pushstring(L, "lighty.con");
2399 lua_gettable(L, LUA_REGISTRYINDEX);
2400 con = lua_touserdata(L, -1);
2402 ===================================================================
2403 --- src/log.c (.../tags/lighttpd-1.4.23)
2404 +++ src/log.c (.../branches/lighttpd-1.4.x)
2406 /* create write pipe and spawn process */
2411 if (pipe(to_log_fds)) {
2412 log_error_write(srv, __FILE__, __LINE__, "ss", "pipe failed: ", strerror(errno));
2417 - switch (pid = fork()) {
2421 close(STDIN_FILENO);
2422 @@ -150,14 +149,14 @@
2425 int log_error_open(server *srv) {
2426 - int close_stderr = 1;
2428 #ifdef HAVE_SYSLOG_H
2429 /* perhaps someone wants to use syslog() */
2430 openlog("lighttpd", LOG_CONS | LOG_PID, LOG_DAEMON);
2432 - srv->errorlog_mode = ERRORLOG_STDERR;
2434 + srv->errorlog_mode = ERRORLOG_FD;
2435 + srv->errorlog_fd = STDERR_FILENO;
2437 if (srv->srvconf.errorlog_use_syslog) {
2438 srv->errorlog_mode = ERRORLOG_SYSLOG;
2439 } else if (!buffer_is_empty(srv->srvconf.errorlog_file)) {
2440 @@ -171,20 +170,36 @@
2442 log_error_write(srv, __FILE__, __LINE__, "s", "server started");
2444 -#ifdef HAVE_VALGRIND_VALGRIND_H
2445 - /* don't close stderr for debugging purposes if run in valgrind */
2446 - if (RUNNING_ON_VALGRIND) close_stderr = 0;
2449 - if (srv->errorlog_mode == ERRORLOG_STDERR && srv->srvconf.dont_daemonize) {
2450 + if (srv->errorlog_mode == ERRORLOG_FD && !srv->srvconf.dont_daemonize) {
2451 /* We can only log to stderr in dont-daemonize mode;
2452 * if we do daemonize and no errorlog file is specified, we log into /dev/null
2455 + srv->errorlog_fd = -1;
2458 - /* move stderr to /dev/null */
2459 - if (close_stderr) openDevNull(STDERR_FILENO);
2460 + if (!buffer_is_empty(srv->srvconf.breakagelog_file)) {
2462 + const char *logfile = srv->srvconf.breakagelog_file->ptr;
2464 + if (srv->errorlog_mode == ERRORLOG_FD) {
2465 + srv->errorlog_fd = dup(STDERR_FILENO);
2467 + fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC);
2471 + if (-1 == (breakage_fd = open_logfile_or_pipe(srv, logfile))) {
2475 + if (STDERR_FILENO != breakage_fd) {
2476 + dup2(breakage_fd, STDERR_FILENO);
2477 + close(breakage_fd);
2479 + } else if (!srv->srvconf.dont_daemonize) {
2480 + /* move stderr to /dev/null */
2481 + openDevNull(STDERR_FILENO);
2486 @@ -235,15 +250,19 @@
2487 switch(srv->errorlog_mode) {
2490 - close(srv->errorlog_fd);
2492 + if (-1 != srv->errorlog_fd) {
2493 + /* don't close STDERR */
2494 + if (STDERR_FILENO != srv->errorlog_fd)
2495 + close(srv->errorlog_fd);
2496 + srv->errorlog_fd = -1;
2499 case ERRORLOG_SYSLOG:
2500 #ifdef HAVE_SYSLOG_H
2504 - case ERRORLOG_STDERR:
2510 switch(srv->errorlog_mode) {
2513 - case ERRORLOG_STDERR:
2515 + if (-1 == srv->errorlog_fd) return 0;
2516 /* cache the generated timestamp */
2517 if (srv->cur_ts != srv->last_generated_debug_ts) {
2518 buffer_prepare_copy(srv->ts_debug_str, 255);
2519 @@ -349,13 +369,10 @@
2520 switch(srv->errorlog_mode) {
2524 buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n"));
2525 write(srv->errorlog_fd, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1);
2527 - case ERRORLOG_STDERR:
2528 - buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n"));
2529 - write(STDERR_FILENO, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1);
2531 case ERRORLOG_SYSLOG:
2532 syslog(LOG_ERR, "%s", srv->errorlog_buf->ptr);
2534 Index: src/proc_open.c
2535 ===================================================================
2536 --- src/proc_open.c (.../tags/lighttpd-1.4.23)
2537 +++ src/proc_open.c (.../branches/lighttpd-1.4.x)
2538 @@ -309,6 +309,14 @@
2541 proc_read_fd_to_buffer(proc.err.fd, err);
2543 + buffer *tmp = buffer_init();
2544 + proc_read_fd_to_buffer(proc.err.fd, tmp);
2545 + if (tmp->used > 0 && write(2, (void*)tmp->ptr, tmp->used) < 0) {
2546 + perror("error writing pipe");
2551 pipe_close(&proc.err);
2553 Index: tests/.cvsignore
2554 ===================================================================
2555 Index: tests/bug-12.conf
2556 ===================================================================
2557 --- tests/bug-12.conf (.../tags/lighttpd-1.4.23)
2558 +++ tests/bug-12.conf (.../branches/lighttpd-1.4.x)
2560 ## bind to localhost (default: all interfaces)
2561 server.bind = "localhost"
2562 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2563 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2564 server.name = "www.example.org"
2565 server.tag = "Apache 1.3.29"
2567 Index: tests/fastcgi-10.conf
2568 ===================================================================
2569 --- tests/fastcgi-10.conf (.../tags/lighttpd-1.4.23)
2570 +++ tests/fastcgi-10.conf (.../branches/lighttpd-1.4.x)
2572 ## bind to localhost (default: all interfaces)
2573 server.bind = "localhost"
2574 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2575 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2576 server.name = "www.example.org"
2577 server.tag = "Apache 1.3.29"
2579 Index: tests/bug-06.conf
2580 ===================================================================
2581 --- tests/bug-06.conf (.../tags/lighttpd-1.4.23)
2582 +++ tests/bug-06.conf (.../branches/lighttpd-1.4.x)
2584 ## bind to localhost (default: all interfaces)
2585 server.bind = "localhost"
2586 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2587 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2588 server.name = "www.example.org"
2589 server.tag = "Apache 1.3.29"
2591 Index: tests/mod-extforward.conf
2592 ===================================================================
2593 Index: tests/var-include.conf
2594 ===================================================================
2595 --- tests/var-include.conf (.../tags/lighttpd-1.4.23)
2596 +++ tests/var-include.conf (.../branches/lighttpd-1.4.x)
2598 ## bind to localhost (default: all interfaces)
2599 server.bind = "localhost"
2600 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2601 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2602 server.name = "www.example.org"
2603 server.tag = "Apache 1.3.29"
2605 Index: tests/404-handler.conf
2606 ===================================================================
2607 --- tests/404-handler.conf (.../tags/lighttpd-1.4.23)
2608 +++ tests/404-handler.conf (.../branches/lighttpd-1.4.x)
2610 ## bind to localhost (default: all interfaces)
2611 server.bind = "localhost"
2612 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2613 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2614 server.name = "www.example.org"
2615 server.tag = "Apache 1.3.29"
2617 Index: tests/lowercase.conf
2618 ===================================================================
2619 --- tests/lowercase.conf (.../tags/lighttpd-1.4.23)
2620 +++ tests/lowercase.conf (.../branches/lighttpd-1.4.x)
2622 ## bind to localhost (default: all interfaces)
2623 server.bind = "localhost"
2624 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2625 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2627 server.force-lowercase-filenames = "enable"
2629 Index: tests/condition.conf
2630 ===================================================================
2631 --- tests/condition.conf (.../tags/lighttpd-1.4.23)
2632 +++ tests/condition.conf (.../branches/lighttpd-1.4.x)
2634 ## bind to localhost (default: all interfaces)
2635 server.bind = "localhost"
2636 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2637 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2638 server.name = "www.example.org"
2639 server.tag = "Apache 1.3.29"
2641 Index: tests/fastcgi-13.conf
2642 ===================================================================
2643 --- tests/fastcgi-13.conf (.../tags/lighttpd-1.4.23)
2644 +++ tests/fastcgi-13.conf (.../branches/lighttpd-1.4.x)
2646 ## bind to localhost (default: all interfaces)
2647 server.bind = "localhost"
2648 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2649 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2650 server.name = "www.example.org"
2651 server.tag = "Apache 1.3.29"
2653 Index: tests/mod-compress.conf
2654 ===================================================================
2655 --- tests/mod-compress.conf (.../tags/lighttpd-1.4.23)
2656 +++ tests/mod-compress.conf (.../branches/lighttpd-1.4.x)
2658 ## bind to localhost (default: all interfaces)
2659 server.bind = "localhost"
2660 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2661 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2662 server.name = "www.example.org"
2665 Index: tests/lighttpd.conf
2666 ===================================================================
2667 --- tests/lighttpd.conf (.../tags/lighttpd-1.4.23)
2668 +++ tests/lighttpd.conf (.../branches/lighttpd-1.4.x)
2670 ## bind to localhost (default: all interfaces)
2671 server.bind = "localhost"
2672 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2673 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2674 server.name = "www.example.org"
2675 server.tag = "Apache 1.3.29"
2677 Index: tests/fastcgi-responder.conf
2678 ===================================================================
2679 --- tests/fastcgi-responder.conf (.../tags/lighttpd-1.4.23)
2680 +++ tests/fastcgi-responder.conf (.../branches/lighttpd-1.4.x)
2682 ## bind to localhost (default: all interfaces)
2683 server.bind = "localhost"
2684 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2685 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2686 server.name = "www.example.org"
2687 server.tag = "Apache 1.3.29"
2689 Index: tests/fastcgi-auth.conf
2690 ===================================================================
2691 --- tests/fastcgi-auth.conf (.../tags/lighttpd-1.4.23)
2692 +++ tests/fastcgi-auth.conf (.../branches/lighttpd-1.4.x)
2694 ## bind to localhost (default: all interfaces)
2695 server.bind = "localhost"
2696 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2697 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2698 server.name = "www.example.org"
2699 server.tag = "Apache 1.3.29"
2701 Index: tests/proxy.conf
2702 ===================================================================
2703 --- tests/proxy.conf (.../tags/lighttpd-1.4.23)
2704 +++ tests/proxy.conf (.../branches/lighttpd-1.4.x)
2706 ## bind to localhost (default: all interfaces)
2707 server.bind = "localhost"
2708 server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
2709 +server.breakagelog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
2710 server.name = "www.example.org"
2711 server.tag = "Proxy"
2713 Index: tests/LightyTest.pm
2714 ===================================================================
2715 --- tests/LightyTest.pm (.../tags/lighttpd-1.4.23)
2716 +++ tests/LightyTest.pm (.../branches/lighttpd-1.4.x)
2721 + my $timeout = 5*10; # 5 secs, select waits 0.1 s
2723 while (0 == $self->listening_on($port)) {
2724 select(undef, undef, undef, 0.1);
2727 # the process is gone, we failed
2728 if (0 != waitpid($child, WNOHANG)) {
2731 + if (0 >= $timeout) {
2732 + diag("Timeout while trying to connect; killing child");
2733 + kill('TERM', $child);
2740 ===================================================================
2741 --- configure.ac (.../tags/lighttpd-1.4.23)
2742 +++ configure.ac (.../branches/lighttpd-1.4.x)
2745 # Process this file with autoconf to produce a configure script.
2747 -AC_INIT([lighttpd], [1.4.23], [contact@lighttpd.net])
2748 +AC_INIT([lighttpd], [1.4.24], [contact@lighttpd.net])
2749 AC_CONFIG_SRCDIR([src/server.c])
2750 AC_CONFIG_HEADER([config.h])
2751 +AC_CONFIG_MACRO_DIR([m4])
2755 @@ -417,12 +418,18 @@
2756 AC_DEFINE([HAVE_LUA], [1], [liblua])
2757 AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2759 - # for debian based systems
2760 - PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [
2761 - AC_DEFINE([HAVE_LUA], [1], [liblua])
2762 - AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2764 + # for debian based systems
2765 + PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [
2766 + AC_DEFINE([HAVE_LUA], [1], [liblua])
2767 + AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2770 + PKG_CHECK_MODULES(LUA, lua-5.1 >= 5.1, [
2771 + AC_DEFINE([HAVE_LUA], [1], [liblua])
2772 + AC_DEFINE([HAVE_LUA_H], [1], [lua.h])
2777 AC_SUBST(LUA_CFLAGS)
2779 Index: doc/.cvsignore
2780 ===================================================================
2781 Index: doc/fastcgi.txt
2782 ===================================================================
2783 --- doc/fastcgi.txt (.../tags/lighttpd-1.4.23)
2784 +++ doc/fastcgi.txt (.../branches/lighttpd-1.4.x)
2787 ( "host" => <string> ,
2788 "port" => <integer> ,
2789 - "socket" => <string>, # either socket
2791 - "bin-path" => <string>, # OPTIONAL
2792 - "bin-environment" => <array>, # OPTIONAL
2793 - "bin-copy-environment" => <array>, # OPTIONAL
2794 + "socket" => <string>, # either socket
2796 + "bin-path" => <string>, # OPTIONAL
2797 + "bin-environment" => <array>, # OPTIONAL
2798 + "bin-copy-environment" => <array>, # OPTIONAL
2799 "mode" => <string>, # OPTIONAL
2800 "docroot" => <string> , # OPTIONAL if "mode"
2801 - # is not "authorizer"
2802 + # is not "authorizer"
2803 "check-local" => <string>, # OPTIONAL
2804 - "min-procs" => <integer>, # OPTIONAL
2805 - "max-procs" => <integer>, # OPTIONAL
2806 - "max-load-per-proc" => <integer>, # OPTIONAL
2807 - "idle-timeout" => <integer>, # OPTIONAL
2808 - "broken-scriptfilename" => <boolean>, # OPTIONAL
2809 + "max-procs" => <integer>, # OPTIONAL
2810 + "broken-scriptfilename" => <boolean>, # OPTIONAL
2811 "disable-time" => <integer>, # optional
2812 - "allow-x-send-file" => <boolean> # optional
2814 + "allow-x-send-file" => <boolean>, # optional
2815 + "kill-signal" => <integer>, # OPTIONAL
2816 + "fix-root-scriptname" => <boolean>,
2821 @@ -127,42 +126,38 @@
2822 :"socket": path to the unix-domain socket
2823 :"mode": is the FastCGI protocol mode.
2824 Default is "responder", also "authorizer"
2825 - mode is implemented.
2826 + mode is implemented.
2827 :"docroot": is optional and is the docroot on the remote
2828 host for default "responder" mode. For
2829 - "authorizer" mode it is MANDATORY and it points
2830 - to docroot for authorized requests. For security
2831 - reasons it is recommended to keep this docroot
2832 + "authorizer" mode it is MANDATORY and it points
2833 + to docroot for authorized requests. For security
2834 + reasons it is recommended to keep this docroot
2835 outside of server.document-root tree.
2836 :"check-local": is optional and may be "enable" (default) or
2837 "disable". If enabled the server first check
2838 - for a file in local server.document-root tree
2839 - and return 404 (Not Found) if no such file.
2840 + for a file in local server.document-root tree
2841 + and return 404 (Not Found) if no such file.
2842 If disabled, the server forward request to
2843 - FastCGI interface without this check.
2844 + FastCGI interface without this check.
2845 :"broken-scriptfilename": breaks SCRIPT_FILENAME in a wat that
2846 PHP can extract PATH_INFO from it (default: disabled)
2847 :"disable-time": time to wait before a disabled backend is checked
2849 :"allow-x-send-file": controls if X-LIGHTTPD-send-file headers
2851 + :"fix-root-scriptname": fix broken path-info split for "/" extension ("prefix")
2855 - :"min-procs": sets the minium processes to start
2856 :"max-procs": the upper limit of the processess to start
2857 - :"max-load-per-proc": maximum number of waiting processes on
2858 - average per process before a new process is
2860 - :"idle-timeout": number of seconds before a unused process
2862 :"bin-environment": put an entry into the environment of
2864 :"bin-copy-environement": clean up the environment and copy
2865 only the specified entries into the fresh
2866 environment of the spawn process
2867 + :"kill-signal": signal to terminate the FastCGI process with,
2868 + defauls to SIGTERM
2874 @@ -171,11 +166,11 @@
2875 fastcgi.server = ( ".php" =>
2876 (( "host" => "127.0.0.1",
2878 - "bin-path" => "/usr/local/bin/php"
2879 + "bin-path" => "/usr/local/bin/php"
2882 (( "host" => "127.0.0.1",
2888 @@ -183,10 +178,10 @@
2890 fastcgi.server = ( "/remote_scripts/" =>
2891 (( "host" => "192.168.0.3",
2894 "check-local" => "disable",
2895 "docroot" => "/" # remote server may use
2896 - # it's own docroot
2897 + # it's own docroot
2903 fastcgi.server = ( "/remote_scripts/" =>
2904 (( "host" => "10.0.0.2",
2907 "docroot" => "/path_to_private_docs",
2908 "mode" => "authorizer"
2910 @@ -318,10 +313,10 @@
2911 $ PHP_FCGI_CHILDREN=384 ./lighttpd -f ./lighttpd.conf
2913 fastcgi.server = ( ".php" =>
2914 - (( "socket" => "/tmp/php.socket",
2915 + (( "socket" => "/tmp/php.socket",
2916 "bin-path" => "/usr/local/bin/php",
2920 "max-load-per-proc" => 4,
2921 "idle-timeout" => 20
2924 "PHP_FCGI_CHILDREN" => "16",
2925 "PHP_FCGI_MAX_REQUESTS" => "10000" ),
2926 "bin-copy-environment" => (
2927 - "PATH", "SHELL", "USER" )
2928 + "PATH", "SHELL", "USER" )
2933 ===================================================================
2935 ===================================================================
2936 --- Makefile.am (.../tags/lighttpd-1.4.23)
2937 +++ Makefile.am (.../branches/lighttpd-1.4.x)
2940 EXTRA_DIST=autogen.sh SConstruct
2942 +ACLOCAL_AMFLAGS = -I m4
2944 distcleancheck_listfiles = find -type f -exec sh -c 'test -f $(srcdir)/{} || echo {}' ';'
2946 ===================================================================
2947 --- autogen.sh (.../tags/lighttpd-1.4.23)
2948 +++ autogen.sh (.../branches/lighttpd-1.4.x)
2951 # Run this to generate all the initial makefiles, etc.
2953 -LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
2954 LIBTOOLIZE_FLAGS="--copy --force"
2955 -ACLOCAL=${ACLOCAL:-aclocal}
2956 -AUTOHEADER=${AUTOHEADER:-autoheader}
2957 -AUTOMAKE=${AUTOMAKE:-automake}
2958 -AUTOMAKE_FLAGS="--add-missing --copy"
2959 -AUTOCONF=${AUTOCONF:-autoconf}
2960 +AUTOMAKE_FLAGS="--add-missing --copy --foreign"
2969 - echo "$ARGV0: running \`$@'"
2971 + echo "$ARGV0: running \`$@' $ARGS"
2975 +## jump out if one of the programs returns 'false'
2978 +## on macosx glibtoolize, others have libtool
2979 +if test x$LIBTOOLIZE = x; then
2980 + if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then
2981 + LIBTOOLIZE=glibtoolize
2982 + elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then
2983 + LIBTOOLIZE=libtoolize-1.5
2984 + elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then
2985 + LIBTOOLIZE=libtoolize
2987 + echo "libtoolize 1.5.x wasn't found, exiting"; exit 0
2991 +## suse has aclocal and aclocal-1.9
2992 +if test x$ACLOCAL = x; then
2993 + if test \! "x`which aclocal-1.9 2> /dev/null | grep -v '^no'`" = x; then
2994 + ACLOCAL=aclocal-1.9
2995 + elif test \! "x`which aclocal19 2> /dev/null | grep -v '^no'`" = x; then
2997 + elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then
3000 + echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0
3004 +if test x$AUTOMAKE = x; then
3005 + if test \! "x`which automake-1.9 2> /dev/null | grep -v '^no'`" = x; then
3006 + AUTOMAKE=automake-1.9
3007 + elif test \! "x`which automake19 2> /dev/null | grep -v '^no'`" = x; then
3008 + AUTOMAKE=automake19
3009 + elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then
3012 + echo "automake 1.9.x wasn't found, exiting"; exit 0
3017 +## macosx has autoconf-2.59 and autoconf-2.60
3018 +if test x$AUTOCONF = x; then
3019 + if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then
3020 + AUTOCONF=autoconf-2.59
3021 + elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then
3022 + AUTOCONF=autoconf259
3023 + elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then
3026 + echo "autoconf 2.59+ wasn't found, exiting"; exit 0
3030 +if test x$AUTOHEADER = x; then
3031 + if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then
3032 + AUTOHEADER=autoheader-2.59
3033 + elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then
3034 + AUTOHEADER=autoheader259
3035 + elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then
3036 + AUTOHEADER=autoheader
3038 + echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0
3043 run $LIBTOOLIZE $LIBTOOLIZE_FLAGS
3044 -run $ACLOCAL $ACLOCAL_FLAGS
3045 +run $ACLOCAL $ACLOCAL_FLAGS -I m4
3047 run $AUTOMAKE $AUTOMAKE_FLAGS
3049 -echo "Now type './configure ...' and 'make' to compile."
3051 +if test "$ARGS" = "" ; then
3052 + echo "Now type './configure ...' and 'make' to compile."
3055 ===================================================================
3056 --- NEWS (.../tags/lighttpd-1.4.23)
3057 +++ NEWS (.../branches/lighttpd-1.4.x)
3064 + * Add T_CONFIG_INT for bigger integers from the config (needed for #1966)
3065 + * Use unsigned int (and T_CONFIG_INT) for max_request_size
3066 + * Use unsigned int for secdownload.timeout (fixes #1966)
3067 + * Keep url/host values from connection to display information while keep-alive in mod_status (fixes #1202)
3068 + * Add server.breakagelog, a "special" stderr (fixes #1863)
3069 + * Fix config evaluation for debug.log-timeouts option (#1529)
3070 + * Add "cgi.execute-x-only" to mod_cgi, requires +x for cgi scripts (fixes #2013)
3071 + * Fix FD_SETSIZE comparision warnings
3072 + * Add "lua-5.1" to searched pkg-config names for lua
3073 + * Fix unused function webdav_lockdiscovery in mod_webdav
3074 + * cmake: Fix crypt lib check
3075 + * cmake: Add -export-dynamic to link flags, fixes build on FreeBSD
3076 + * Set FD_CLOEXEC for bound sockets before pipe-logger forks (fixes #2026)
3077 + * Reset ignored signals to SIG_DFL before exec() in fastcgi/scgi (fixes #2029)
3078 + * Show "no uri specified -> 400" error only when "debug.log-request-header-on-error" is enabled (fixes #2030)
3079 + * Fix hanging connection in mod_scgi (fixes #2024)
3080 + * Allow digits in hostnames in more places (fixes #1148)
3081 + * Use connection_reset instead of handle_request_done for cleanup callbacks
3082 + * Change mod_expire to append Cache-Control instead of overwriting it (fixes #1997)
3083 + * Allow all comparisons for $SERVER["socket"] - only bind for "=="
3084 + * Remove strptime failed message (fixes #2031)
3085 + * Fix issues found with clang analyzer
3086 + * Try to fix server.tag issue with localized svnversion
3087 + * Fix handling network-write return values (#2024)
3088 + * Use disable-time in fastcgi for all disables after errors, default is 1sec (fixes #2040)
3089 + * Remove adaptive spawning code from fastcgi (was disabled for a long time)
3090 + * Allow mod_mysql_vhost to use stored procedures (fixes #2011, thx Ben Brown)
3091 + * Fix ipv6 in mod_proxy (fixes #2043)
3092 + * Print errors from include_shell to stderr
3093 + * Set tm.tm_isdst = 0 before mktime() (fixes #2047)
3094 + * Use linux-epoll by default if available (fixes #2021, thx Olaf van der Spek)
3095 + * Print an error if you use too many captures in a regex pattern (fixes #2059)
3096 + * Combine Cache-Control header value in mod_expire to existing HTTP header if header already added by other modules (fixes #2068)
3098 +- 1.4.23 - 2009-06-19
3099 * Added some extra warning options in cmake and fix the resulting warnings (unused/static functions)
3100 * New lighttpd man page (moved it to section 8) (fixes #1875)
3101 * Create rrd file for empty rrdfile in mod_rrdtool (#1788)
3102 Index: CMakeLists.txt
3103 ===================================================================