httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael H. Voase" <>
Subject proposed patch to mod_cgi
Date Mon, 18 Jan 1999 16:16:05 GMT


    I would like to propose a patch to the CGI module that should allow
the 'blocked post read' problem  to be alleviated. You see , when you
have a CGI script  that has accepted a post client that may have bugs
for whatever reason
that script will block on its read to the CGI module . This I percieve
be a high source of CGI script failure . The reasoning for my
are as follows :

    When a script is started , it has two actions to work with . The GET

and the POST methods .

    Now if that script has been designed to accept  the POST  then it
probably read the stdin descriptor for the data that it is meant to
recieve . In the mod_cgi module for Apache , ap_should_client_block
makes the decision if data should be returned from the client (is
    If .. by some reason , should ap-should_client_block decide that no
data is to be read from the client , it will return zero and CGI
immediately to read from the script .....

    err .... KABOOM ....

    The script is already blocked on the read from Apache and thus its
poor , simple , fall-through-the-top ,single thread will never be
to send to the read from Apache and as such Apache will do a blocking
read until the timer runs out .

    One way to solve this problem is to write extraneously convoluted
scripts to check if there is like *any* data to read from stdin . If so
then read it ......maybe ...

    The other is to do a blocking read on stdin and if there is no data
read from the client then the CGI module turns around and says :

CGI: no client block

    This way , the script will read the message from stdin , parse it
and say nope , noclient block available , and happily go on to put
the rest of its kruft to stdout .

    Think about it ....

Cheers Mik Voase.

PS this patch goes on the end of ap_should_client_block , just after
its last }  with no semi colons in between ...

      else {
        len_read = ap_bwrite(script_out,"CGI: no client block\0",21);
        if (len_read<=0)
            return log_scripterror( r , conf , HTTP_CONFLICT ,
                APLOG_NOERRNO , "CGI script MUST read the client

This way everybody stays synchronized with everone else .

 /~\     /~\            CASTLE INDUSTRIES PTY. LTD.
 | |_____| |            Incorporated 1969. in N.S.W., Australia
 |         |            Phone +612 6562 1345 Fax +612 6567 1449
 |   /~\   |            Web
 |   [ ]   |            Michael H. Voase.  Director.
~~~~~~~~~~~~~~          Cause Linux Flies and Windoze Dies ... 'nuf said.

View raw message