Re: how to break out of FCGX_Accept_r
"Emil A Eklund" <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
You could use a non blocking FCGX_Accept_r and check for the shutdown
condition yourself. Thats the way I've solved it.
state = WORKER_RUNNING;
FCGX_InitRequest(&request, listenSocket, FCGI_FAIL_ACCEPT_ON_INTR);
while (1) {
while (state != WORKER_TERMINATE) {
rc = FCGX_Accept_r(&request);
if (rc != -9999) { break; }
}
if ((rc != 0) && (state != WORKER_TERMINATE)) { log(LOG_CRITICAL, "Accept
Failed, thread killed!"); break; }
if (state == WORKER_TERMINATE) { break; }
...
FCGX_Finish_r(&request);
}
For windows there is no built in way to make Accept_r non-blocking (or at
least was not when I last checked), however I have a patch somewhere that
implements that, I'll try to dig it up.
/Emil
----- Original Message -----
From: "Andrej van der Zee" <[email protected]>
To: <fastcgi-developers-xGejAJT2w6xVgU18Zptdi0EOCMrvLtNR@public.gmane.org>
Sent: Friday, November 18, 2005 10:40
Subject: [FASTCGI] how to break out of FCGX_Accept_r
> 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/
>
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/