You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Sa...@nokia.com on 2001/08/02 13:44:00 UTC

Persistent cgi...?

Hi,

I need to write a module to accomodate persistent connections to cgi-scripts
for an http-like protocol in Apache 2.0...

Is that sort of thing provided for in the CGI/1.1 spec? I've gone through
the specs and they don't say anything about a CGI (or for that matter any
server-side-scripting environment) scripts having to terminate before the
server actually pushes the output to the client... 
So if I'm running a script that takes a finite amount of time to finish
processing a web of URLs in some way, then shouldn't it be able to give me
feedback AS the script processes the URLs? If so, then shouldn't there be
some sort of provision in mod_cgi?

i.e., mod_cgi calls apr_bucket_pipe_create after a script has been run and
headers from stdout scanned, but the flush-bucket is passed AFTER this
pipe-bucket... which means that even if a script, that might run for several
minutes, might fflush(stdout) several times, output will still loop about in
core_output_filter in core.c...

Is there any way of getting around this??

One way I could think of was to read the script output in cgi_handler and
call create_transient_bucket instead of a creating a piped bucket, but I
don't know how that'll affect performance... Also - is there some way for a
module to determine when a connection has been reset by the browser, so that
mod_cgi could actually kill the script when that happens?

-Sapan

Re: Persistent cgi...?

Posted by Ryan Bloom <rb...@covalent.net>.
The content-length filter handles this for you.  Basically, the content-length 
filter reads from the pipe bucket until it doesn't get data.  Once it doesn't get
data, it flushes the data that it has, and waits for more data.

IOW, you shouldn't have to do anything.   :-)

Ryan

On Thursday 02 August 2001 04:44, Sapan.Bhatia@nokia.com wrote:
> Hi,
>
> I need to write a module to accomodate persistent connections to
> cgi-scripts for an http-like protocol in Apache 2.0...
>
> Is that sort of thing provided for in the CGI/1.1 spec? I've gone through
> the specs and they don't say anything about a CGI (or for that matter any
> server-side-scripting environment) scripts having to terminate before the
> server actually pushes the output to the client...
> So if I'm running a script that takes a finite amount of time to finish
> processing a web of URLs in some way, then shouldn't it be able to give me
> feedback AS the script processes the URLs? If so, then shouldn't there be
> some sort of provision in mod_cgi?
>
> i.e., mod_cgi calls apr_bucket_pipe_create after a script has been run and
> headers from stdout scanned, but the flush-bucket is passed AFTER this
> pipe-bucket... which means that even if a script, that might run for
> several minutes, might fflush(stdout) several times, output will still loop
> about in core_output_filter in core.c...
>
> Is there any way of getting around this??
>
> One way I could think of was to read the script output in cgi_handler and
> call create_transient_bucket instead of a creating a piped bucket, but I
> don't know how that'll affect performance... Also - is there some way for a
> module to determine when a connection has been reset by the browser, so
> that mod_cgi could actually kill the script when that happens?
>
> -Sapan

-- 

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