deinitializing after fastcgiloop doesnt work
Albert Leidinger <albert.leidinger-kt1KeoM4Q/BvMmomy+XrYrNldLUNz+W/@public.gmane.org>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Organization | die graphikschmiede |
| Message-ID | <[email protected]> |
Hi!
I´m using fastcgi for 2 months now. The performance is great!
But there is still a big problem in my Perl script. Google didnt help
and I also didn´t find help in the old messages on the list.
So please have a look at the following Perl-Script. If you dont find
anything, maybe you could just copy the script to your machine and tell
me what it does on your computer.
thanks for your help
Albert
PROBLEM DESCRIPTION:
I want to use shared memory in a future version of my app. So the memory
has to be allocated on startup and freed on shutdown.
The first is done before the request-loop, the second after the last run
of the request loop.
This last part is the problem. It seems my perl-fcgi-scripts are just
stopped within the loop and therefor the code after the loop isnt
executed (very fatal with shared memory!)
In the following example script the shared memory is represented by
opening a file and writing to it at startup, and unlinking it on shutdown.
On my machines (SuSE Linux 9.1, Perl 5.8.3, Apache 2.0.49,
apache2_mod_fastcgi 2.4.0) the file is opened when the fcgi ist called
first, but not unlinked when stopping Apache.
As I said - the code after the loop isnt executed (seems to me at least).
Here is the script:
#!/usr/bin/perl
use FCGI;
use strict;
my $count = 0;
my $handling_request = 0;
my $exit_requested = 0;
my $request = FCGI::Request();
open( TESTFILE, '>test.tmp' );
print TESTFILE "test\n";
close ( TESTFILE );
sub sig_handler {
$exit_requested = 1;
warn "got signal $_[0]";
}
$SIG{USR1} = \&sig_handler;
$SIG{TERM} = \&sig_handler;
$SIG{PIPE} = 'IGNORE';
while ($handling_request = ($request->Accept() >= 0)) {
&do_request;
$handling_request = 0;
last if $exit_requested;
}
unlink( 'test.tmp' );
warn "normal-exit\n";
exit(0);
sub do_request() {
print("Content-type: text/html\r\n\r\n", ++$count);
warn("request: $count\n");
$request->Finish();
}
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/