problems with UNIX domain sockets
"Craig Barkhouse" <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <006801c480cb$aa44ab80$6501a8c0@fireball> |
Hi all, I've implemented the webserver side of the FastCGI protocol. I've built some test apps in Perl using the Perl FCGI library version 0.67, which is based on the FastCGI development kit version 2.4.0. I'm having two problems. #1 The library closes the connection if it's a UNIX domain socket and it does not receive any data within 2 seconds. There is a big long comment in os_unix.c about how this is supposed to work around an obscure bug in Linux 2.0.x and SCO UnixWare wherein you could accept a connection that was already closed on the client side, blah blah blah. I see in the mailing list archives that this has been mentioned before, but I don't think anything has been done about it yet. The problem I'm having is that my webserver creates a connection to the FastCGI app at init time and keeps it open (persistent); it only sends data to the FastCGI app when there is an actual request, which probably won't be in the first 2 seconds. I've chosen this model for performance reasons. Shouldn't this kludge be off by default, and only on for those systems that are affected? By "those systems that are affected", I mean you could either use #ifdefs based on architecture, or perhaps even a simple simulation could be performed at compile time to determine if the system is affected. I know that I can make a special versin of the FCGI library myself to disable the kludge, but given that my aim is to incorporate FastCGI support into a *webserver*, I want that webserver to be able to work with a wide variety of FastCGI apps out there. This kludge is very annoying. #2 To try to work around the kludge without modifying the Perl FCGI library, I decided that I could have my webserver send an FCGI_GET_VALUES message to the FastCGI app immediately after connecting to it. Here is a hexdump of the exact message I send, in case somebody can spot something I'm doing wrong: 01 09 00 00 00 30 00 00 0E 00 46 43 47 49 5F 4D .....0....FCGI_M 41 58 5F 43 4F 4E 4E 53 0D 00 46 43 47 49 5F 4D AX_CONNS..FCGI_M 41 58 5F 52 45 51 53 0F 00 46 43 47 49 5F 4D 50 AX_REQS..FCGI_MP 58 53 5F 43 4F 4E 4E 53 XS_CONNS The problem is I never get a response back; the FastCGI app reads in the three name-value pairs but then enters a perma-blocked state trying to read more name-value pairs. In fcgiapp.c, line 1464, ProcessManagementRecord() calls ReadParams() which starts to read the name-value pairs. But it doesn't know when to stop. Once it has exhausted the three pairs, it keeps on going and calls FCGX_GetChar() again, which ends up doing a read() because there's no more data. It sits in the read(), so ReadParams() never returns, and consequently we never get back into ProcessManagementRecord() so that it can send back the FCGI_GET_VALUES_RESULT message. BTW this problem is not specific to UNIX domain sockets. So in order to get the FCGI_GET_VALUES / FCGI_GET_VALUES_RESULT exchange to work, I would have to hack up the FCGI library which is what I wanted to avoid. Basically I have no way of communicating reliably with an off-the-shelf FCGI library over a UNIX domain socket in my model where I don't necessarily send data immediately after connecting. Any help is greatly appreciated! ___________________________________ fastcgi-developers mailing list http://fastcgi.com/fastcgi-developers/