version 1.1.1.1, 1999/10/13 17:48:51
|
version 1.4, 1999/12/22 17:18:04
|
Line 10
|
Line 10
|
# HUP restarts |
# HUP restarts |
# USR1 tries to open connections again |
# USR1 tries to open connections again |
|
|
# 6/4/99,6/5,6/7,6/8,6/9,6/10,6/11,6/12,7/14,7/19,10/8,10/9 Gerd Kortemeyer |
# 6/4/99,6/5,6/7,6/8,6/9,6/10,6/11,6/12,7/14,7/19, |
|
# 10/8,10/9,10/15,11/18,12/22 Gerd Kortemeyer |
# based on nonforker from Perl Cookbook |
# based on nonforker from Perl Cookbook |
# - server who multiplexes without forking |
# - server who multiplexes without forking |
|
|
Line 30 open (CONFIG,"/etc/httpd/conf/access.con
|
Line 31 open (CONFIG,"/etc/httpd/conf/access.con
|
while ($configline=<CONFIG>) { |
while ($configline=<CONFIG>) { |
if ($configline =~ /PerlSetVar/) { |
if ($configline =~ /PerlSetVar/) { |
my ($dummy,$varname,$varvalue)=split(/\s+/,$configline); |
my ($dummy,$varname,$varvalue)=split(/\s+/,$configline); |
|
chomp($varvalue); |
$perlvar{$varname}=$varvalue; |
$perlvar{$varname}=$varvalue; |
} |
} |
} |
} |
Line 121 sub logthis {
|
Line 123 sub logthis {
|
print $fh "$local ($$): $message\n"; |
print $fh "$local ($$): $message\n"; |
} |
} |
|
|
|
|
|
sub logperm { |
|
my $message=shift; |
|
my $execdir=$perlvar{'lonDaemons'}; |
|
my $now=time; |
|
my $local=localtime($now); |
|
my $fh=IO::File->new(">>$execdir/logs/lonnet.perm.log"); |
|
print $fh "$now:$message:$local\n"; |
|
} |
|
|
# ---------------------------------------------------- Fork once and dissociate |
# ---------------------------------------------------- Fork once and dissociate |
|
|
$fpid=fork; |
$fpid=fork; |
Line 214 unless (
|
Line 226 unless (
|
exit; |
exit; |
}; |
}; |
# --------------------------------------- Send a ping to make other end do USR1 |
# --------------------------------------- Send a ping to make other end do USR1 |
print $remotesock "ping\n"; |
print $remotesock "init\n"; |
|
$answer=<$remotesock>; |
|
print $remotesock "$answer"; |
$answer=<$remotesock>; |
$answer=<$remotesock>; |
chomp($answer); |
chomp($answer); |
&logthis("Ping reply for $conserver: >$answer<"); |
&logthis("Init reply for $conserver: >$answer<"); |
sleep 5; |
sleep 5; |
print $remotesock "pong\n"; |
print $remotesock "pong\n"; |
$answer=<$remotesock>; |
$answer=<$remotesock>; |
Line 240 if ($cipher=new IDEA $cipherkey) {
|
Line 254 if ($cipher=new IDEA $cipherkey) {
|
&logthis("Error: Could not establish secure connection, $conserver!"); |
&logthis("Error: Could not establish secure connection, $conserver!"); |
} |
} |
|
|
|
# ----------------------------------------- We're online, send delayed messages |
|
|
|
my @allbuffered; |
|
my $path="$perlvar{'lonSockDir'}/delayed"; |
|
opendir(DIRHANDLE,$path); |
|
@allbuffered=grep /\.$conserver$/, readdir DIRHANDLE; |
|
closedir(DIRHANDLE); |
|
my $dfname; |
|
map { |
|
$dfname="$path/$_"; |
|
&logthis($dfname); |
|
my $wcmd; |
|
{ |
|
my $dfh=IO::File->new($dfname); |
|
$cmd=<$dfh>; |
|
} |
|
chomp($cmd); |
|
my $bcmd=$cmd; |
|
if ($cmd =~ /^encrypt\:/) { |
|
my $rcmd=$cmd; |
|
$rcmd =~ s/^encrypt\://; |
|
chomp($rcmd); |
|
my $cmdlength=length($rcmd); |
|
$rcmd.=" "; |
|
my $encrequest=''; |
|
for (my $encidx=0;$encidx<=$cmdlength;$encidx+=8) { |
|
$encrequest.= |
|
unpack("H16",$cipher->encrypt(substr($rcmd,$encidx,8))); |
|
} |
|
$cmd="enc:$cmdlength:$encrequest\n"; |
|
} |
|
|
|
print $remotesock "$cmd\n"; |
|
$answer=<$remotesock>; |
|
chomp($answer); |
|
if ($answer ne '') { |
|
unlink("$dfname"); |
|
&logthis("Delayed $cmd to $conserver: >$answer<"); |
|
&logperm("S:$conserver:$bcmd"); |
|
} |
|
} @allbuffered; |
|
|
# ------------------------------------------------------- Listen to UNIX socket |
# ------------------------------------------------------- Listen to UNIX socket |
unless ( |
unless ( |