Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.890.2.2 and 1.892

version 1.890.2.2, 2007/06/25 23:31:33 version 1.892, 2007/06/18 22:52:33
Line 214  sub reply { Line 214  sub reply {
 # ----------------------------------------------------------- Send USR1 to lonc  # ----------------------------------------------------------- Send USR1 to lonc
   
 sub reconlonc {  sub reconlonc {
       my ($lonid) = @_;
       my $hostname = &hostname($lonid);
       if ($lonid) {
    my $peerfile="$perlvar{'lonSockDir'}/$hostname";
    if ($hostname && -e $peerfile) {
       &logthis("Trying to reconnect lonc for $lonid ($hostname)");
       my $client=IO::Socket::UNIX->new(Peer    => $peerfile,
        Type    => SOCK_STREAM,
        Timeout => 10);
       if ($client) {
    print $client ("reset_retries\n");
    my $answer=<$client>;
    #reset just this one.
       }
    }
    return;
       }
   
     &logthis("Trying to reconnect lonc");      &logthis("Trying to reconnect lonc");
     my $loncfile="$perlvar{'lonDaemons'}/logs/lonc.pid";      my $loncfile="$perlvar{'lonDaemons'}/logs/lonc.pid";
     if (open(my $fh,"<$loncfile")) {      if (open(my $fh,"<$loncfile")) {
Line 7977  sub get_dns { Line 7995  sub get_dns {
           
     sub get_iphost {      sub get_iphost {
  my ($ignore_cache) = @_;   my ($ignore_cache) = @_;
   
  if (!$ignore_cache) {   if (!$ignore_cache) {
     if (%iphost) {      if (%iphost) {
  return %iphost;   return %iphost;
Line 7991  sub get_dns { Line 8008  sub get_dns {
  return %iphost;   return %iphost;
     }      }
  }   }
   
  # get yesterday's info for fallback  
  my %old_name_to_ip;  
  my ($ip_info,$cached)=  
     &Apache::lonnet::is_cached_new('iphost','iphost');  
  if ($cached) {  
     %old_name_to_ip = %{$ip_info->[1]};  
  }  
   
  my %name_to_host = &all_names();   my %name_to_host = &all_names();
  foreach my $name (keys(%name_to_host)) {   foreach my $name (keys(%name_to_host)) {
     my $ip;      my $ip;
     if (!exists($name_to_ip{$name})) {      if (!exists($name_to_ip{$name})) {
  $ip = gethostbyname($name);   $ip = gethostbyname($name);
  if (!$ip || length($ip) ne 4) {   if (!$ip || length($ip) ne 4) {
     if (defined($old_name_to_ip{$name})) {      &logthis("Skipping name $name no IP found");
  $ip = $old_name_to_ip{$name};      next;
  &logthis("Can't find $name defaulting to old $ip");  
     } else {  
  &logthis("Name $name no IP found");  
  next;  
     }  
  } else {  
     $ip=inet_ntoa($ip);  
  }   }
    $ip=inet_ntoa($ip);
  $name_to_ip{$name} = $ip;   $name_to_ip{$name} = $ip;
     } else {      } else {
  $ip = $name_to_ip{$name};   $ip = $name_to_ip{$name};
Line 8027  sub get_dns { Line 8029  sub get_dns {
  }   }
  &Apache::lonnet::do_cache_new('iphost','iphost',   &Apache::lonnet::do_cache_new('iphost','iphost',
       [\%iphost,\%name_to_ip,\%lonid_to_ip],        [\%iphost,\%name_to_ip,\%lonid_to_ip],
       48*60*60);        24*60*60);
   
  return %iphost;   return %iphost;
     }      }

Removed from v.1.890.2.2  
changed lines
  Added in v.1.892


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>