]> granicus.if.org Git - apache/commitdiff
Fix streaming output from an nph- CGI script. CGI:IRC now
authorJeff Trawick <trawick@apache.org>
Fri, 25 Oct 2002 15:18:53 +0000 (15:18 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 25 Oct 2002 15:18:53 +0000 (15:18 +0000)
works.

core output filter needs to detect when no more data is available from
a pipe for a while so that it can flush what is already there

normally, content-length filter handles this but for nph- script
we don't have content-length filter in place

PR:             8482

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97301 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/core.c

diff --git a/CHANGES b/CHANGES
index 56f79206129ee15bc7d222a43a490f1769a24301..23d02882857e7551874a3e77699c9fac86bb5363 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.44
 
+  *) Fix streaming output from an nph- CGI script.  CGI:IRC now
+     works.  PR 8482  [Jeff Trawick]
+
   *) More accurate logging of bytes sent in mod_logio when
      the client terminates the connection before the response
      is completely sent  [Bojan Smojver <bojan@rexursive.com>]
index e607a75b8fe21c64b672529375a328916f47af37..8cabd7d48e7ce0874e9c9a38a0156308381df74a 100644 (file)
@@ -3663,6 +3663,7 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
     conn_rec *c = f->c;
     core_net_rec *net = f->ctx;
     core_output_filter_ctx_t *ctx = net->out_ctx;
+    apr_read_type_e eblock = APR_NONBLOCK_READ;
 
     if (ctx == NULL) {
         ctx = apr_pcalloc(c->pool, sizeof(*ctx));
@@ -3738,7 +3739,16 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
                 const char *str;
                 apr_size_t n;
 
-                rv = apr_bucket_read(e, &str, &n, APR_BLOCK_READ);
+                rv = apr_bucket_read(e, &str, &n, eblock);
+                if (APR_STATUS_IS_EAGAIN(rv)) {
+                    /* send what we have so far since we shouldn't expect more
+                     * output for a while...  next time we read, block
+                     */
+                    more = apr_brigade_split(b, e);
+                    eblock = APR_BLOCK_READ;
+                    break;
+                }
+                eblock = APR_NONBLOCK_READ;
                 if (n) {
                     if (!fd) {
                         if (nvec == MAX_IOVEC_TO_WRITE) {