httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@covalent.net>
Subject Re: cvs commit: httpd-2.0 STATUS
Date Mon, 02 Jul 2001 20:30:00 GMT

> > IMO the decision to flush or not and how to read from the pipe should be entirely
> > controlled by mod_cgi.  We need a function similar to the old ap_send_fb() code.

You can't leave this up to mod_cgi.  As soon as the data leaves mod_cgi,
it is officially out of mod_cgi's hands.  Later filters must just work
correctly.

> Hi Bill,
> I was wondering if there was a generic way of doing this in a generic
> fashion so that ALL dynamic content modules (perl/jk/proxy etc)
> would be affected (maybe putting it into the socket/pipe bucket read
> functions)

IMNSHO, the correct way to do this, is to fix the C-L filter, not modify
the generator.  The filter is doing a blocking read, when it should do a
non-blocking read.  The C-L filter, in other words, is getting in the way
of getting things done, instead of acting innocently.  The whole point of
always going through the C-L filter, is that it should never delay
information.

The patch below is relying on all filters to honor the FLUSH bucket type,
which is incorrect.  Just make the core filters work properly, and you
will solve this problem.

Ryan


> > Index: mod_cgi.c
> > ===================================================================
> > RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
> > retrieving revision 1.92
> > diff -u -u -r1.92 mod_cgi.c
> > --- mod_cgi.c 2001/02/28 15:24:05 1.92
> > +++ mod_cgi.c 2001/07/02 18:26:53
> > @@ -768,16 +768,43 @@
> >   }
> >
> >   if (!r->header_only) {
> > +            #define IOBUFSIZE 8192
> > +            apr_status_t rv;
> > +            char buf[IOBUFSIZE];
> > +            int len = IOBUFSIZE;
> > +            apr_interval_time_t timeout;
> > +
> >              bb = apr_brigade_create(r->pool);
> > -     b = apr_bucket_pipe_create(script_in);
> > -     APR_BRIGADE_INSERT_TAIL(bb, b);
> > -            b = apr_bucket_eos_create();
> > -     APR_BRIGADE_INSERT_TAIL(bb, b);
> > -     ap_pass_brigade(r->output_filters, bb);
> > - }
> > +
> > +            /* Set the pipe to non-blocking for the first read */
> > +            apr_file_pipe_timeout_get(script_in, &timeout);
> > +            apr_file_pipe_timeout_set(script_in, 0);
> >
> > -        log_script_err(r, script_err);
> > - apr_file_close(script_err);
> > +            while (!r->connection->aborted) {
> > +                len = IOBUFSIZE;
> > +                rv = apr_file_read(script_in, buf, &len);
> > +                if (rv == APR_EOF || (rv == APR_SUCCESS && len == 0)) {
> > +                    b = apr_bucket_eos_create();
> > +                    APR_BRIGADE_INSERT_TAIL(bb, b);
> > +                    ap_pass_brigade(r->output_filters, bb);
> > +                    break;
> > +                }
> > +                else if (rv == APR_EAGAIN) {
> > +                    /* Set the pipe to blocking and flush the output stream. */
> > +                    apr_file_pipe_timeout_set(script_in, timeout);
> > +                    b = apr_bucket_flush_create();
> > +                    APR_BRIGADE_INSERT_TAIL(bb, b);
> > +                    ap_pass_brigade(r->output_filters, bb);
> > +                }
> > +                else {
> > +                    b = apr_bucket_transient_create(buf, len);
> > +                    APR_BRIGADE_INSERT_TAIL(bb, b);
> > +                    ap_pass_brigade(r->output_filters, bb);
> > +                }
> > +            }
> > +            log_script_err(r, script_err);
> > +            apr_file_close(script_err);
> > +        }
> >      }
> >
> >      if (script_in && nph) {
> >
>
>
>
>


_____________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
Covalent Technologies			rbb@covalent.net
-----------------------------------------------------------------------------




Mime
View raw message