]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* modules/ssl/ssl_engine_io.c (ssl_io_filter_output): Use non-blocking
authorJoe Orton <jorton@apache.org>
Fri, 30 Jan 2004 12:58:08 +0000 (12:58 +0000)
committerJoe Orton <jorton@apache.org>
Fri, 30 Jan 2004 12:58:08 +0000 (12:58 +0000)
bucket reads whilst data remains available; flush when a read returns
EAGAIN.  Fixes streaming nph- CGI scripts over SSL.

PR: 21944
Reviewed by: Jeff Trawick, Justin Erenkrantz

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

CHANGES
modules/ssl/ssl_engine_io.c

diff --git a/CHANGES b/CHANGES
index aad901e1b4bf90b1b31e90324795229ef81d6d3c..5f5fe4f72c54547a6403bb1bdbe1aa5fb0d83a32 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.49
 
+  *) mod_ssl: Fix streaming output from an nph- CGI script. PR 21944
+     [Joe Orton]
+
   *) mod_usertrack no longer inspects the Cookie2 header for
      the cookie name. PR 11475.  [Chris Darrochi <chrisd pearsoncmg.com>]
 
index c5b8e80d41e9c3c2e4b2791cea108c13b9091cea..9ff358b9219feea8b408864ded1d20fccf3c921f 100644 (file)
@@ -1282,6 +1282,8 @@ static apr_status_t ssl_io_filter_output(ap_filter_t *f,
     apr_status_t status = APR_SUCCESS;
     ssl_filter_ctx_t *filter_ctx = f->ctx;
     bio_filter_in_ctx_t *inctx;
+    bio_filter_out_ctx_t *outctx;
+    apr_read_type_e rblock = APR_NONBLOCK_READ;
 
     if (f->c->aborted) {
         apr_brigade_cleanup(bb);
@@ -1294,6 +1296,8 @@ static apr_status_t ssl_io_filter_output(ap_filter_t *f,
     }
 
     inctx = (bio_filter_in_ctx_t *)filter_ctx->pbioRead->ptr;
+    outctx = (bio_filter_out_ctx_t *)filter_ctx->pbioWrite->ptr;
+
     /* When we are the writer, we must initialize the inctx
      * mode so that we block for any required ssl input, because
      * output filtering is always nonblocking.
@@ -1313,8 +1317,6 @@ static apr_status_t ssl_io_filter_output(ap_filter_t *f,
          */
         if (APR_BUCKET_IS_EOS(bucket) || APR_BUCKET_IS_FLUSH(bucket)) {
             if (bio_filter_out_flush(filter_ctx->pbioWrite) < 0) {
-                bio_filter_out_ctx_t *outctx = 
-                       (bio_filter_out_ctx_t *)(filter_ctx->pbioWrite->ptr);
                 status = outctx->rc;
                 break;
             }
@@ -1344,7 +1346,19 @@ static apr_status_t ssl_io_filter_output(ap_filter_t *f,
             const char *data;
             apr_size_t len;
             
-            status = apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ);
+            status = apr_bucket_read(bucket, &data, &len, rblock);
+
+            if (APR_STATUS_IS_EAGAIN(status)) {
+                /* No data available: flush... */
+                if (bio_filter_out_flush(filter_ctx->pbioWrite) < 0) {
+                    status = outctx->rc;
+                    break;
+                }
+                rblock = APR_BLOCK_READ;
+                continue; /* and try again with a blocking read. */
+            }
+
+            rblock = APR_NONBLOCK_READ;
 
             if (!APR_STATUS_IS_EOF(status) && (status != APR_SUCCESS)) {
                 break;