[FASTCGI] FCGI does not fail accept on interrupt

Dean Banks connexity2 at gmail.com
Mon Mar 7 12:55:31 EST 2011


I have a multithreaded FCGI application developed in C that is based on 
the threaded.c example in the SDK.  I am using supervisor to hook it for 
use with nginx.  It works very well, except for the following issue--

Each thread has its own FCGI handle (like threaded.c), and each call to 
FCGX_InitRequest() sets the FCGI_FAIL_ACCEPT_ON_INTR flag.  I have a 
signal handler set up to catch SIGINT and gracefully wind the process 
down.  The signal handler calls FCGX_ShutdownPending() in an attempt to 
do this.

When there are no incoming requests, all threads except one are blocked 
on the FCGX_Accept_r() mutex, and one is blocked on FCGX_Accept_r(), as 
expected.  If a SIGINT is issued, all of the threads that are blocked on 
the mutex will properly abort once the mutex is released and they have a 
chance to call FCGX_Accept_r().  The trouble is that the thread that is 
blocking on FCGX_Accept_r() does not abort when SIGINT is thrown. One 
additional incoming request is required to get past the FCGX_Accept_r() 
block and release that particular thread.

After extensive searching, I could not find a good example of the proper 
use of FCGI_FAIL_ACCEPT_ON_INTR, so I can't help but wonder if I'm 
getting it wrong.  What is the proper way to get FCGX_Accept_r() to 
release its block in a process shutdown scenario?

Cheers,

Dean


More information about the FastCGI-developers mailing list