Re: Problems with multi-threaded FastCGI server

Thierry Pierron <t.pierron-E+nNfmQdIM/[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
On Apr 18, 2006, at 15:20, Thierry Pierron wrote:

> First, I know that this has already been asked on this list, but I 
> wonder the lack of answer. The problem is simple : I can't make work 
> the multi-threaded example provided with libfcgi. I'm running fastcgi 
> with Apache 2.0.54 on Win32 with fcgi sdk that can be found here 
> http://www.fastcgi.com/dist/.
>
> As far as I've investigated, I got a timeout in the apache log, saying 
> that fastcgi server has not respond for 30 seconds. It seems that 
> whenever a thread leave the FCGX_Accept_r() function, the connection 
> is broken as soon as another thread enter it : I can see the content 
> of the first FCGX_FPrintF, just before the sleep(), and then I got the 
> classical apache Internal error message.
>
> If I protect the whole loop by a mutex, it works fine, though it's 
> like having mono-threaded application.
>
> I included the threaded.c example slighty modified to work with Win32 
> API. I wonder if anyone succeed to make it work as a FastCGI server...

Well, well, well, as a quick workaround, you can use socket-based 
communication instead of default pipe-based, by specifying -port option 
in httpd.conf when starting your fastcgi server. This works well,at 
least the multi-threaded example works as expected.

As far as I've investigated in the source of libfcgi, pipe-based 
communication does not work at all in a multi-threaded context, since a 
single handle seems to be used to communicate with server and 
deconnection is performed for each FCGX_Accept :-( Wonder why it is not 
more clearly stated in the doc ...
-- 
Thierry Pierron


___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.