From: Jeff Trawick Date: Tue, 10 Oct 2000 04:11:35 +0000 (+0000) Subject: Write all of the request body to the child, not just what the kernel X-Git-Tag: APACHE_2_0_ALPHA_8~429 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a0da4d6e5134c1fecdea596f3c4c7a039dc574a;p=apache Write all of the request body to the child, not just what the kernel would accept on the first write. Because the pipe is non-blocking (via setting an APR timeout), we have to send in a loop. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86495 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 6a02344a4f..f791c139ff 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -579,7 +579,8 @@ static int cgi_handler(request_rec *r) */ if (ap_should_client_block(r)) { int dbsize, len_read; - apr_ssize_t bytes_written; + apr_ssize_t bytes_written, bytes_to_write; + apr_status_t rv; if (conf->logname) { dbuf = apr_pcalloc(r->pool, conf->bufbytes + 1); @@ -598,9 +599,17 @@ static int cgi_handler(request_rec *r) memcpy(dbuf + dbpos, argsbuffer, dbsize); dbpos += dbsize; } - bytes_written = len_read; - (void) apr_write(script_out, argsbuffer, &bytes_written); - if (bytes_written < len_read) { + /* Keep writing data to the child until done or too much time + * elapses with no progress or an error occurs. + */ + bytes_written = 0; + do { + bytes_to_write = len_read - bytes_written; + rv = apr_write(script_out, argsbuffer + bytes_written, + &bytes_to_write); + bytes_written += bytes_to_write; + } while (rv == APR_SUCCESS && bytes_written < len_read); + if (rv != APR_SUCCESS || bytes_written < len_read) { /* silly script stopped reading, soak up remaining message */ while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN) > 0) { /* dump it */