Commit ed748e82 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

small refactoring.

parent 9bbc67e1
......@@ -41,8 +41,6 @@ use Sympa::Log;
use Sympa::SOAP;
use Sympa::SOAP::Transport;
my $birthday = [stat $PROGRAM_NAME]->[9];
## Load sympa config
unless (Conf::load()) {
printf STDERR
......@@ -83,12 +81,8 @@ my $all_lists = Sympa::List::get_lists('*');
# Soap part
##############################################################################
my $server = Sympa::SOAP::Transport->new();
$server->dispatch_with({'urn:sympasoap' => 'Sympa::SOAP'});
#$server->dispatch_to('--modulesdir--', 'Sympa::SOAP');
$server->handle($birthday, $PROGRAM_NAME);
Sympa::SOAP::Transport->new(cookie_expire => $Conf::Conf{'cookie_expire'})
->dispatch_with({'urn:sympasoap' => 'Sympa::SOAP'})->handle;
__END__
......
......@@ -29,6 +29,7 @@ package Sympa::SOAP::Transport;
use strict;
use warnings;
use English qw(-no_match_vars);
use SOAP::Transport::HTTP;
use Sympa::Log;
......@@ -40,6 +41,18 @@ our @ISA = qw(SOAP::Transport::HTTP::FCGI);
my $log = Sympa::Log->instance;
sub new {
my $class = shift;
return $class if ref $class;
my %options = @_;
my $self = $class->SUPER::new();
$self->{_ss_birthday} = [stat $PROGRAM_NAME]->[9] if $PROGRAM_NAME;
$self->{_ss_cookie_expire} = $options{cookie_expire} || 0;
$self;
}
sub request {
my $self = shift;
......@@ -86,11 +99,9 @@ sub response {
if (my $response = $_[0]) {
if (defined $ENV{'SESSION_ID'}) {
my $expire = $main::param->{'user'}{'cookie_delay'}
|| $Conf::Conf{'cookie_expire'};
my $cookie =
Sympa::Session::soap_cookie2($ENV{'SESSION_ID'},
$ENV{'SERVER_NAME'}, $expire);
$ENV{'SERVER_NAME'}, $self->{_ss_cookie_expire});
$response->headers->push_header('Set-Cookie2' => $cookie);
}
}
......@@ -99,10 +110,8 @@ sub response {
}
## Redefine FCGI's handle subroutine
sub handle ($$$) {
my $self = shift->new;
my $birthday = shift;
my $myname = shift;
sub handle {
my $self = shift->new;
my ($r1, $r2);
my $fcgirq = $self->{_fcgirq};
......@@ -112,13 +121,14 @@ sub handle ($$$) {
$r2 = $self->SOAP::Transport::HTTP::CGI::handle;
# Exit if script itself has changed.
if (defined $birthday and $myname) {
my $age = [stat $myname]->[9];
my $birthday = $self->{_ss_birthday};
if (defined $birthday and $PROGRAM_NAME) {
my $age = [stat $PROGRAM_NAME]->[9];
if (defined $age and $birthday != $age) {
$log->syslog(
'notice',
'Exiting because %s has changed since FastCGI server started',
$myname
$PROGRAM_NAME
);
exit(0);
}
......
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