Subject: | unloading data after last Request |
Hi again!
There is another problem.
I want to use shared memory with fastcgi processes. Therefore the first dynamic process creates the shared memory with IPC::Shareable, the following processes connect to it.
So its very important, that the creating process also frees the shared memory when it (and Apache) are stopped.
The solution should be putting these function after the Accept-Loop. The doc says the call for Accept returns -1 when the processManager gets the TERM signal, so the while-loop gets skipped and the following code is executed.
But the following script isnt working on my machine:
#!/usr/bin/perl
use FCGI;
use strict;
my $count = 0;
my $handling_request = 0;
my $exit_requested = 0;
my $request = FCGI::Request();
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;
}
warn "exiting normal\n";
exit(0);
sub do_request() {
print("Content-type: text/html\r\n\r\n", ++$count);
$request->Finish();
}
I get the "got signal TERM" warn in the Apache ErrorLog, but I dont get the "exiting normal" log entry.
It seems the script is just terminated at the beginning of the loop.
Is this a bug? Or just another incompatibility?
Thanks
Albert
Apache 2.0.49
mod_fastcgi 2.4.0
FCGI 0.67