On 20 November 2002, I said:
> OK, so OS X 10.2 still won't get along with fcgi.py. I'll attach two
> patches (one relative to Quixote 0.5.1, one relative to CVS) that
> simplify and clarify fcgi.py's _startup(), and fix it so it should work
> on OS X.
Whoops, I patched without thinking. OS X is not just different here,
it's (IMHO) broken -- at least for the purpose of using getpeername() to
distinguish a socket that's really a socket from a socket that's just a
wrapper around stdin. The patch I supplied broke Quixote's FastCGI
support (at least on Linux) completely.
Let's try that again, shall we? First, the test CGI script is different
again:
--issocket.cgi-----------------------------------------
#!/www/python/bin/python
import sys, socket, errno
print "Content-Type: text/plain\n"
print "ENOTCONN = %d" % errno.ENOTCONN
print "ENOTSOCK = %d" % errno.ENOTSOCK
try:
s = socket.fromfd(sys.stdin.fileno(),
socket.AF_INET,
socket.SOCK_STREAM)
s.getsockname()
except socket.error, err:
print err
else:
print "getsockname() succeeded: %r" % n
-------------------------------------------------------
If you're running *any* platform other than Linux 2.4/glibc 2.3/
Apache 1.3, can you please:
* drop the above script into your cgi-bin directory
* run it from the command line, eg.
python /www/cgi-bin/issocket.cgi
and tell me what it says
* run it via your web browser, eg. point your browser at
http://localhost/cgi-bin/issocket.cgi
and tell me what it says
Then if you're *really* nice, you can try whichever of the attached
patches works for you and see if Quixote still works via both CGI and
FastCGI. (It does for me, now.)
Greg
--
Greg Ward - software developer gward@mems-exchange.org
MEMS Exchange http://www.mems-exchange.org