On Thu, Jan 22, 2004 at 11:22:14AM -0500, Jeff Trawick wrote:
> pud wrote:
> >okay, please forgive me, s/mod_cgi/mod_ssl/g, sorry...
> >
> >
> >>hey, sorry to disturb you, but,,,
> >>
> >>i read in the apache2 changelog that you fixed an streaming bug
> >>in the mod_cgi - but i think it still exists...
> >>(at least in the debian-version)
> >>i can't get cgi::irc to work and always get an timeout-error
> >>if the nph-cgi is called
> >>
> >>have you got any hint for me, where to look in the sources
> >>of mod_cgi? ...or anywhere/anything else?
> 
> I don't know much about mod_ssl, but I'd guess the issue is in
> ssl_engine_io.c:ssl_io_filter_output().
> 
> Other filters such as content-length filter know that it is nice to 
> flush data already read to the network when a bucket read would block. 
> However, this filter only flushes to the network with a real flush 
> bucket is received.
>
> Disclaimer: first time I've ever looked at that filter...  Actual 
> reality may vary

That seems to be exactly the issue, thanks Jeff.  I'll check this in
after a little more testing, works for me for simple nph scripts:

Index: ssl_engine_io.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_engine_io.c,v
retrieving revision 1.113
diff -u -r1.113 ssl_engine_io.c
--- ssl_engine_io.c     1 Jan 2004 13:26:21 -0000       1.113
+++ ssl_engine_io.c     23 Jan 2004 10:44:05 -0000
@@ -1370,6 +1370,8 @@
     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;
 
     if (f->c->aborted) {
         apr_brigade_cleanup(bb);
@@ -1382,6 +1384,8 @@
     }
 
     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.
@@ -1401,8 +1405,6 @@
          */
         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;
             }
@@ -1432,7 +1434,19 @@
             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)) {
+                /* read would block => flush, then retry using a blocking read. */
+                if (bio_filter_out_flush(filter_ctx->pbioWrite) < 0) {
+                    status = outctx->rc;
+                    break;
+                }
+                rblock = APR_BLOCK_READ;
+                continue; /* and try that again. */
+            } else {
+                rblock = APR_NONBLOCK_READ;
+            }
 
             if (!APR_STATUS_IS_EOF(status) && (status != APR_SUCCESS)) {
                 break;

Reply via email to