[Zope-dev] danger: FCGIServer.py rev 1.5 breaks fastcgi for me.

Anthony Baxter anthony@interlink.com.au
Mon, 29 Nov 1999 11:49:28 +1100


I'm running Zope on a Linux box (redhat 5.2) and have
mod_fastcgi_SNAP_Oct06 compiled into Apache 1.3.9 on
a Solaris x86 box. This patch, from FCGIServer.py r1.4 to r1.5
utterly breaks FCGI support. Any attempt to connect via FCGI
makes zope go into an infinite loop, gobbling up memory.

Yes, this is in the collector now, but it's worth mentioning
it to zope-dev so anyone else who is trying to make this work
doesn't end up screaming and ranting...

(As an aside - how do I get CVS to checkout a particular revision
of a particular file? Can I do this?)

(Aside2: classic.zope.org/cgi-bin/cvsweb.cgi is just hanging for me... :(

the log entry for this revision:

revision 1.5
date: 1999/11/22 14:48:07;  author: brian;  state: Exp;  lines: +9 -1
Added P.Eby patch to deal with IRIX cgi-fcgi where the client doesnt
seem to know when its done sending stdin and ZServer hangs waiting for
it. The patch makes ZServer ignore stdin if there is no Content-Length
and makes it stop looking if Content-Length or more bytes have already
been read.
----------------------------

patch from r1.4 to r1.5
Index: FCGIServer.py
===================================================================
RCS file: /cvs-repository/Zope2/ZServer/FCGIServer.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FCGIServer.py       1999/11/16 02:25:44     1.4
+++ FCGIServer.py       1999/11/22 14:48:07     1.5
@@ -430,6 +430,10 @@
         elif rec.recType == FCGI_PARAMS:
             if rec.contentLength == 0:  # end of the stream
                 self.remainingRecs = self.remainingRecs - 1
+                self.content_length=string.atoi(self.env.get(
+                    'CONTENT_LENGTH','0'))
+                if self.content_length==0:
+                    self.remainingRecs = self.remainingRecs - 1
             else:
                 self.env.update(rec.values)
 
@@ -447,6 +451,10 @@
                     self.stdin=t
                     self.using_temp_stdin=1
                 self.stdin.write(rec.content)
+                self.content_length = self.content_length - rec.contentLength
+                if self.content_length <= 0:
+                    self.remainingRecs = self.remainingRecs - 1
+ 
 
         # read some filter data
         elif rec.recType == FCGI_DATA:
@@ -457,7 +465,7 @@
 
 
         # We've processed the record.  Now what do we do?
-        if self.remainingRecs:
+        if self.remainingRecs > 0:
             # prepare to get the next record
             self.setInitialState()