Blocking FCGI due to only one blocking client

WWW administrator (webadmin@physik.fu-berlin.de)
Sun, 26 Jan 1997 02:33:36 +0100 (MET)

From: WWW administrator <webadmin@physik.fu-berlin.de>
Message-Id: <199701260133.CAA23038@axp2.physik.fu-berlin.de>
Subject: Blocking FCGI due to only one blocking client
To: fastcgi-developers@OpenMarket.com
Date: Sun, 26 Jan 1997 02:33:36 +0100 (MET)

Hi!
At first: I'm not a "fastcgi insider", so probably my problem and its
solution is obsolete (especially with V1.4.3 of mod_fastcgi for the apache
server).

I'm using mod_fastcgi (V 1.4) with apache 1.1.1 to serialize my CGIs (using
the option -processes 1).
But sometimes when a (F)CGI produces a huge amount of data (~100kB) and the
client which requested this (F)CGI blocks, all further requests of all other
clients will block, because "DrainReqOutbuf()" in mod_fastcgi waits for the
return of the bwrite() (which is waiting for the client to accept data).
I have no problems with blocking FCGIs due to incomplete requests because
apache seems not to call the FCGhandler before the complete request is read
in a buffer.

So, I added the option "-buffsize" to be able to choose another buffer size
of the reqOutbufPtr: Now CgiToClientBuffer() will be able to clear the
inbufPtr and the loop won't stop to read the output of the (F)CGI (until
the whole buffer is filled - but that has to be avoided).
But there's another reason why the loop can stop: When select() returns with
(status==0 --> timeout is reached) mod_fastcgi will try to send data to the
client using DrainReqOutbuf() again - so I added some lines to FastCgiDoWork()
to prevent it from using DrainReqOutbuf() if bwrite() would block.

This is my solution for this problem - but probably there's another
and better solution: Now I have to patch all new dists of the mod_fastcgi
(and there's is even yet a new one). If there's anybody outthere who has
the same problem and a solution (but remember: I can't simply use -processes
because I use fastcgi even to _serialize_ my CGIs) answer me directly!

If you are interested in my solution (it seems to work pretty well), you
can download it here:
http://www.physik.fu-berlin.de/~webadmin/mod_fastcgi.c.gz

I think it should run on all plattforms, but I developed this on a FreeBSD
machine and that's the only plattform, what is really tested.

Gunnar

-- 
###################################################################
#  Gunnar Pruessner (webadmin)                                    #
#                                                                 #
#  email         : webadmin@www.physik.fu-berlin.de               #
#  phone         : germany-(0)30-838-3179                         #
#  office        : 1.3.26                                         #
#  postal address: Freie Universitaet Berlin                      #
#                  Fachbereich Physik, WWW-Server Administration  #
#                  Arnimallee 14                                  #
#                  14195 Berlin (Germany)                         #
###################################################################