From 56d25f9b506b6219f157d93984d3a7a33ab90e44 Mon Sep 17 00:00:00 2001 From: robs Date: Wed, 18 Jun 2003 00:25:17 +0000 Subject: [PATCH] Do the connect() to the application *after* collecting a chunk of client data. This reinstates the pre-2.4.0 behaviour. James Jurach [muaddib@erf.net]. Modified Files: mod_fastcgi.c CHANGES --- CHANGES | 6 +++++- mod_fastcgi.c | 41 ++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 3e19af7..f9212e2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ 2.4.1 - *) Remove an assert on WIN that was triggering when spawn() failed. + *) Do the connect() to the application *after* collecting a chunk + of client data. This reinstates the pre-2.4.0 behaviour. + James Jurach [muaddib@erf.net]. + + *) Remove an assert that was triggering on WIN when spawn() failed. *) Provide the NO_SUEXEC_FOR_AP_USER_N_GROUP macro for building mod_fastcgi with the AP13 suexec behaviour (don't use suexec diff --git a/mod_fastcgi.c b/mod_fastcgi.c index 0e418fa..3125d64 100644 --- a/mod_fastcgi.c +++ b/mod_fastcgi.c @@ -3,7 +3,7 @@ * * Apache server module for FastCGI. * - * $Id: mod_fastcgi.c,v 1.151 2003/02/04 00:29:41 robs Exp $ + * $Id: mod_fastcgi.c,v 1.152 2003/06/18 00:25:17 robs Exp $ * * Copyright (c) 1995-1996 Open Market, Inc. * @@ -1583,6 +1583,7 @@ static int npipe_io(fcgi_request * const fr) struct timeval dynamic_last_io_time = {0, 0}; int did_io = 1; pool * const rp = r->pool; + int is_connected = 0; DWORD recv_count = 0; @@ -1650,6 +1651,17 @@ SERVER_SEND: case STATE_SERVER_SEND: + if (! is_connected) + { + if (open_connection_to_fs(fr) != FCGI_OK) + { + ap_kill_timeout(r); + return HTTP_INTERNAL_SERVER_ERROR; + } + + is_connected = 1; + } + if (! send_pending && BufferLength(fr->serverOutputBuffer)) { Buffer * b = fr->serverOutputBuffer; @@ -1968,7 +1980,7 @@ static int socket_io(fcgi_request * const fr) struct timeval dynamic_last_io_time = {0, 0}; fd_set read_set; fd_set write_set; - int nfds = fr->fd + 1; + int nfds = 0; int select_status = 1; int idle_timeout; int rv; @@ -1977,6 +1989,7 @@ static int socket_io(fcgi_request * const fr) int client_recv = FALSE; env_status env; pool *rp = r->pool; + int is_connected = 0; if (fr->role == FCGI_RESPONDER) { @@ -2001,8 +2014,6 @@ static int socket_io(fcgi_request * const fr) ap_hard_timeout("FastCGI request processing", r); - set_nonblocking(fr, TRUE); - for (;;) { FD_ZERO(&read_set); @@ -2040,6 +2051,19 @@ SERVER_SEND: case STATE_SERVER_SEND: + if (! is_connected) + { + if (open_connection_to_fs(fr) != FCGI_OK) + { + ap_kill_timeout(r); + return HTTP_INTERNAL_SERVER_ERROR; + } + + set_nonblocking(fr, TRUE); + is_connected = 1; + nfds = fr->fd + 1; + } + if (BufferLength(fr->serverOutputBuffer)) { FD_SET(fr->fd, &write_set); @@ -2298,15 +2322,6 @@ static int do_work(request_rec * const r, fcgi_request * const fr) ap_register_cleanup(rp, (void *)fr, cleanup, ap_null_cleanup); ap_unblock_alarms(); - ap_hard_timeout("connect() to FastCGI server", r); - - /* Connect to the FastCGI Application */ - if (open_connection_to_fs(fr) != FCGI_OK) - { - ap_kill_timeout(r); - return HTTP_INTERNAL_SERVER_ERROR; - } - #ifdef WIN32 if (fr->using_npipe_io) { -- 2.11.4.GIT