logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: mod_fcgid - process ending
Author
soubok



Joined: 14 Aug 2007
Posts: 5
Location: France

PostPosted: Tue 14 Aug '07 16:02    Post subject: mod_fcgid - process ending Reply with quote

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

PostPosted: Wed 15 Aug '07 16:00    Post subject: Reply with quote

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

PostPosted: Wed 15 Aug '07 16:14    Post subject: Reply with quote

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

PostPosted: Wed 15 Aug '07 18:41    Post subject: Reply with quote

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

PostPosted: Thu 16 Aug '07 11:10    Post subject: Reply with quote

This behavior is really annoying for me Sad
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

PostPosted: Thu 16 Aug '07 20:43    Post subject: Reply with quote

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

PostPosted: Fri 17 Aug '07 19:28    Post subject: Reply with quote

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

PostPosted: Fri 17 Aug '07 19:42    Post subject: Reply with quote

Thanks a lot Steffen for retransmitting Smile
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

PostPosted: Mon 27 Aug '07 14:08    Post subject: Reply with quote

Any news ?
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Mon 27 Aug '07 19:42    Post subject: Reply with quote

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


Reply to topic   Topic: mod_fcgid - process ending View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules