ef98216b12
- 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
112 lines
3.6 KiB
Plaintext
112 lines
3.6 KiB
Plaintext
$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:
|