--- loncom/Attic/lonc 1999/10/26 20:24:47 1.2 +++ loncom/Attic/lonc 1999/11/18 19:52:46 1.3 @@ -11,7 +11,7 @@ # 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,10/15 Gerd Kortemeyer +# 10/8,10/9,10/15,11/18 Gerd Kortemeyer # based on nonforker from Perl Cookbook # - server who multiplexes without forking @@ -122,6 +122,16 @@ sub logthis { 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 $fpid=fork; @@ -243,6 +253,42 @@ if ($cipher=new IDEA $cipherkey) { &logthis("Error: Could not establish secure connection, $conserver!"); } +# ----------------------------------------- We're online, send delayed messages + + my $path="$perlvar{'lonSockDir'}/delayed"; + my $dfname; + while ($dfname=<$path/*.$conserver>) { + my $wcmd; + { + my $dfh=IO::File->new($dfname); + $wcmd=<$dfh>; + } + my ($server,$cmd)=split(/:/,$wcmd); + 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 ($server): >$answer<"); + &logperm("S:$conserver:$bcmd"); + } + } # ------------------------------------------------------- Listen to UNIX socket unless (