Re: how to break out of FCGX_Accept_r

Michael Hartley <michael.hartley-jEoFCcbHCOQze0waTqBjZBy+ShKaMYb+@public.gmane.org>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
Andrej van der Zee <andrej@...> writes:

> 
> Hi,
> 
> I would like to know if it is possible to break out of the pending 
> accept-call and how to do this. The problem is, I have to shutdown the 
> fast-cgi after it has been runnig for 8 hours. In c++, when I schedule a 
> threat that wakes up after 8 hours, the fast-cgi main-loop can be in two 
> situations:
> 1) It is handling a request. In this case the fast-cgi should finish 
> after handling it. This can be done with FCGX_ShutdownPending(). No 
> problem here.
> 2) The main-loop is in FCGX_Accept_r waiting for an incomming 
> connection. In this case I would like to break out of the accept and 
> immideately finish the fast-cgi application.
> 
> In the threat that wakes up after 8 hours, I was thinking to raise a 
> signal in case 2 only. Though, how can I be sure that we are in case 2? 
> Setting flags before entering and after leaving FCGX_Accept_r is not 
> sufficient because my treat may wakeup when fast-cgi already accpeted a 
> request, but has not come out of FCGX_Accept_r yet.
> 
> Any ideas? Any other solutions?
> 
> Thanks a bunch!
> 
> Andrej
> ___________________________________
> fastcgi-developers mailing list
> http://fastcgi.com/fastcgi-developers/
> 
> 

Hi,

The FCGX_Accept_r( &request ) breaks out of it's internal socket listener loop 
occasionally; I think it's every 100ms but you will need to check the source 
code.

To cause the FCGX_Accept_r call to exit before a new request has arrived, call 
FCGX_ShutdownPending();

providing your Accept_r loop is like this:

while( (FCGX_Accept_r( &request ) >= 0)  ){ 

your application will not try to process the null &request pointer.

Kind regards

Michael Hartley.

___________________________________
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.