Commit 9bbc67e1 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

[bug] FCGI scripts will not always restart when they are updated.

- exit(0) was caused only when script file is updated: On binary distributions this assumption is not true. If would be caused anytime when timestamp is simply changed.
- The time of startup was used for origin of change. Timestamp of script would be used instead.
- Non-standard `SCRIPT_FILENAME` environment variable was referred. Instead use `$PROGRAM_NAMe` (`$0`).
parent 65519850
......@@ -41,7 +41,7 @@ use Sympa::Log;
use Sympa::SOAP;
use Sympa::SOAP::Transport;
my $birthday = time;
my $birthday = [stat $PROGRAM_NAME]->[9];
## Load sympa config
unless (Conf::load()) {
......@@ -88,7 +88,7 @@ my $server = Sympa::SOAP::Transport->new();
$server->dispatch_with({'urn:sympasoap' => 'Sympa::SOAP'});
#$server->dispatch_to('--modulesdir--', 'Sympa::SOAP');
$server->handle($birthday);
$server->handle($birthday, $PROGRAM_NAME);
__END__
......
......@@ -1008,7 +1008,7 @@ unless (Conf::data_structure_uptodate()) {
our %in;
my $query;
 
my $birthday = time;
my $birthday = [stat $PROGRAM_NAME]->[9];
 
my $bulk = Sympa::Bulk->new;
 
......@@ -1965,14 +1965,15 @@ while ($query = new_loop()) {
send_html('main.tt2');
}
 
# exit if wwsympa.fcgi itself has changed
if ($ENV{'SCRIPT_FILENAME'}
and Sympa::Tools::File::get_mtime($ENV{'SCRIPT_FILENAME'}) >
$birthday) {
$log->syslog('notice',
'Exiting because %s has changed since fastcgi server started',
$ENV{'SCRIPT_FILENAME'});
exit(0);
# Exit if wwsympa.fcgi itself has changed.
if (defined $birthday) {
my $age = [stat $PROGRAM_NAME]->[9];
if (defined $age and $birthday != $age) {
$log->syslog('notice',
'Exiting because %s has changed since FastCGI server started',
$PROGRAM_NAME);
exit(0);
}
}
 
}
......
......@@ -31,13 +31,15 @@ use strict;
use warnings;
use SOAP::Transport::HTTP;
use Sympa::Log;
use Sympa::Session;
use Sympa::Tools::File;
use Sympa::Tools::WWW;
# 'base' pragma doesn't work here
our @ISA = qw(SOAP::Transport::HTTP::FCGI);
my $log = Sympa::Log->instance;
sub request {
my $self = shift;
......@@ -97,25 +99,30 @@ sub response {
}
## Redefine FCGI's handle subroutine
sub handle ($$) {
sub handle ($$$) {
my $self = shift->new;
my $birthday = shift;
my $myname = shift;
my ($r1, $r2);
my $fcgirq = $self->{_fcgirq};
## If fastcgi changed on disk, die
## Apache will restart the process
while (($r1 = $fcgirq->Accept()) >= 0) {
$r2 = $self->SOAP::Transport::HTTP::CGI::handle;
if (Sympa::Tools::File::get_mtime($ENV{'SCRIPT_FILENAME'}) >
$birthday) {
exit(0);
# Exit if script itself has changed.
if (defined $birthday and $myname) {
my $age = [stat $myname]->[9];
if (defined $age and $birthday != $age) {
$log->syslog(
'notice',
'Exiting because %s has changed since FastCGI server started',
$myname
);
exit(0);
}
}
# print
# "Set-Cookie: sympa_altemails=olivier.salaun%40cru.fr; path=/; expires=Tue , 19-Oct-2004 14 :08:19 GMT\n";
}
return undef;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment