add patches from upstream via Brad:

- disable warning "CLOSE-read"
- reset tlsext_server_name in connection_reset - fixes random
hostnames in the $HTTP["host"] conditional
- mod_fastcgi: fix mod_fastcgi packet parsing
- mod_fastcgi: Don't reconnect after connect() succeeded
This commit is contained in:
sthen 2009-11-08 13:16:40 +00:00
parent 8498558def
commit ef98216b12
3 changed files with 148 additions and 1 deletions

View File

@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.61 2009/10/27 23:02:11 sthen Exp $
# $OpenBSD: Makefile,v 1.62 2009/11/08 13:16:40 sthen Exp $
SHARED_ONLY= Yes
COMMENT= secure, fast, compliant, and very flexible web-server
DISTNAME= lighttpd-1.4.24
PKGNAME= ${DISTNAME}p0
CATEGORIES= www net
MASTER_SITES= ${HOMEPAGE}/download/

View File

@ -0,0 +1,35 @@
$OpenBSD: patch-src_connections_c,v 1.10 2009/11/08 13:16:40 sthen Exp $
--- src/connections.c.orig Mon Oct 19 08:15:24 2009
+++ src/connections.c Sat Nov 7 19:58:41 2009
@@ -807,6 +807,9 @@ int connection_reset(server *srv, connection *con) {
CLEAN(authed_user);
CLEAN(server_name);
CLEAN(error_handler);
+#if defined USE_OPENSSL && ! defined OPENSSL_NO_TLSEXT
+ CLEAN(tlsext_server_name);
+#endif
#undef CLEAN
#define CLEAN(x) \
@@ -1250,8 +1253,10 @@ static handler_t connection_handle_fdevent(void *s, vo
if (b > 0) {
char buf[1024];
+#if 0
log_error_write(srv, __FILE__, __LINE__, "sdd",
"CLOSE-read()", con->fd, b);
+#endif
/* */
read(con->fd, buf, sizeof(buf));
@@ -1621,8 +1626,10 @@ int connection_state_machine(server *srv, connection *
}
if (b > 0) {
char buf[1024];
+#if 0
log_error_write(srv, __FILE__, __LINE__, "sdd",
"CLOSE-read()", con->fd, b);
+#endif
/* */
read(con->fd, buf, sizeof(buf));

View File

@ -0,0 +1,111 @@
$OpenBSD: patch-src_mod_fastcgi_c,v 1.5 2009/11/08 13:16:40 sthen Exp $
--- src/mod_fastcgi.c.orig Sat Nov 7 19:41:52 2009
+++ src/mod_fastcgi.c Sat Nov 7 19:41:43 2009
@@ -2416,8 +2416,8 @@ typedef struct {
static int fastcgi_get_packet(server *srv, handler_ctx *hctx, fastcgi_response_packet *packet) {
chunk * c;
- size_t offset = 0;
- size_t toread = 0;
+ size_t offset;
+ size_t toread;
FCGI_Header *header;
if (!hctx->rb->first) return -1;
@@ -2428,20 +2428,22 @@ static int fastcgi_get_packet(server *srv, handler_ctx
packet->padding = 0;
packet->request_id = 0;
+ offset = 0; toread = 8;
/* get at least the FastCGI header */
for (c = hctx->rb->first; c; c = c->next) {
- size_t weWant = sizeof(*header) - (packet->b->used - 1);
size_t weHave = c->mem->used - c->offset - 1;
- if (weHave > weWant) weHave = weWant;
+ if (weHave > toread) weHave = toread;
if (packet->b->used == 0) {
buffer_copy_string_len(packet->b, c->mem->ptr + c->offset, weHave);
} else {
buffer_append_string_len(packet->b, c->mem->ptr + c->offset, weHave);
}
+ toread -= weHave;
+ offset = weHave; /* skip offset bytes in chunk for "real" data */
- if (packet->b->used >= sizeof(*header) + 1) break;
+ if (0 == toread) break;
}
if ((packet->b->used == 0) ||
@@ -2449,7 +2451,9 @@ static int fastcgi_get_packet(server *srv, handler_ctx
/* no header */
buffer_free(packet->b);
- log_error_write(srv, __FILE__, __LINE__, "sdsds", "FastCGI: header too small:", packet->b->used, "bytes <", sizeof(FCGI_Header), "bytes");
+ if (hctx->plugin_data->conf.debug) {
+ log_error_write(srv, __FILE__, __LINE__, "sdsds", "FastCGI: header too small:", packet->b->used, "bytes <", sizeof(FCGI_Header), "bytes, waiting for more data");
+ }
return -1;
}
@@ -2461,9 +2465,6 @@ static int fastcgi_get_packet(server *srv, handler_ctx
packet->type = header->type;
packet->padding = header->paddingLength;
- /* the first bytes in packet->b are the header */
- offset = sizeof(*header);
-
/* ->b should only be the content */
buffer_copy_string_len(packet->b, CONST_STR_LEN("")); /* used == 1 */
@@ -2477,7 +2478,7 @@ static int fastcgi_get_packet(server *srv, handler_ctx
buffer_append_string_len(packet->b, c->mem->ptr + c->offset + offset, weHave);
- /* we only skipped the first 8 bytes as they are the fcgi header */
+ /* we only skipped the first bytes as they belonged to the fcgi header */
offset = 0;
}
@@ -3080,34 +3081,17 @@ static handler_t fcgi_write_request(server *srv, handl
if (ret < 0) {
switch(errno) {
+ case EPIPE:
case ENOTCONN:
+ case ECONNRESET:
/* the connection got dropped after accept()
- *
- * this is most of the time a PHP which dies
- * after PHP_FCGI_MAX_REQUESTS
- *
+ * we don't care about that - if you accept() it, you have to handle it.
*/
- if (hctx->wb->bytes_out == 0 &&
- hctx->reconnects < 5) {
- usleep(10000); /* take away the load of the webserver
- * to give the php a chance to restart
- */
- fcgi_reconnect(srv, hctx);
-
- return HANDLER_WAIT_FOR_FD;
- }
-
- /* not reconnected ... why
- *
- * far@#lighttpd report this for FreeBSD
- *
- */
-
- log_error_write(srv, __FILE__, __LINE__, "ssosd",
- "[REPORT ME] connection was dropped after accept(). reconnect() denied:",
+ log_error_write(srv, __FILE__, __LINE__, "ssosb",
+ "connection was dropped after accept() (perhaps the fastcgi process died),",
"write-offset:", hctx->wb->bytes_out,
- "reconnect attempts:", hctx->reconnects);
+ "socket:", hctx->proc->connection_name);
return HANDLER_ERROR;
default: