Author |
|
soubok
Joined: 14 Aug 2007 Posts: 5 Location: France
|
Posted: Tue 14 Aug '07 16:02 Post subject: mod_fcgid - process ending |
|
|
Hello,
I am creating a JavaScript based FastCGI module (http://code.google.com/p/jslibs/wiki/jsfastcgi) and I noticed that when mod_fcgid is shutting down my FastCGI process ( because MaxRequestsPerProcess or ProcessLifeTime, or ... ) my ReleaseData function is never called.
InitData();
while ( Accept() >= 0 ) {
...
}
ReleaseData();
It there a way to tell mod_fcgid to generate an 'error' to make Accept return instead of killing the FastCGI process ?
or do I miss something ?
Thanks,
Franck.
PS: WinXP SP2, Apache 2.2.4, mod_fcgid-2.2-w32, lib fcgi-2.4.0 |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Wed 15 Aug '07 16:00 Post subject: |
|
|
If you are using the FastCGI Developer's Kit, perhaps you mean: Code: | while ( FCGI_Accept() >= 0 ) { | instead of Code: | while ( Accept() >= 0 ) { |
FCGI_Accept() is defined in fcgi_stdio.h.
-tom- |
|
Back to top |
|
soubok
Joined: 14 Aug 2007 Posts: 5 Location: France
|
Posted: Wed 15 Aug '07 16:14 Post subject: |
|
|
Yes, I am using FastCGI Developer's Kit and Accept() is a wrapper to FCGX_Accept() |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Wed 15 Aug '07 18:41 Post subject: |
|
|
You're right, FCGI_Accept (or Accept) never returns when the process ends.
It looks like it is just an undesirable characteristic of FastCGI on Windows which uses named pipes.
If you look at the FastCGI source (search for ShutdownRequestThread),
when the connection is a Windows named pipe (listenType == FD_PIPE_SYNC), the process just dies.
-tom- |
|
Back to top |
|
soubok
Joined: 14 Aug 2007 Posts: 5 Location: France
|
Posted: Thu 16 Aug '07 11:10 Post subject: |
|
|
This behavior is really annoying for me
I tried to use atexit(&FCGX_Finish); without success.
Do yo know a workaround to make FCGX_Accept to return with an ""error"" when the process has to exit ?
Franck. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Thu 16 Aug '07 20:43 Post subject: |
|
|
I contacted the author. When he answers I come back here.
Steffen |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Fri 17 Aug '07 19:28 Post subject: |
|
|
This I received:
Ryan wrote: | It's very ugly to "make" accept() return, this issue should be solved on the javascript side? Does he try _onexit() on Win32? |
|
|
Back to top |
|
soubok
Joined: 14 Aug 2007 Posts: 5 Location: France
|
Posted: Fri 17 Aug '07 19:42 Post subject: |
|
|
Thanks a lot Steffen for retransmitting
It seems correct that after a "accept() return" the program MUST end.
The drawback of onexit is that it breaks the flow of the interpreted JS code and it is dangerous to call another code while the first has not ended.
I think that it is legitimate to make some cleanup tasks ( remove temp files, close DB connections, ...) after Accept() even if it is scripted.
Franck. |
|
Back to top |
|
soubok
Joined: 14 Aug 2007 Posts: 5 Location: France
|
Posted: Mon 27 Aug '07 14:08 Post subject: |
|
|
Any news ? |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Mon 27 Aug '07 19:42 Post subject: |
|
|
I suspect that Ryan is a mod_fcgid developer (although I'm not sure).
mod_fcgid just runs the already-linked executable.
The problem seems to be in the FastCGI C Development Kit which provides the libfcgi.dll library.
I doubt that the mod_fcgid people can fix that.
Maybe you should post something to the fastcgi-developers list about the poor Windows shutdown handling in os_win32.c?
-tom- |
|
Back to top |
|