Diff for /loncom/lond between versions 1.213 and 1.214

version 1.213, 2004/07/27 10:50:37 version 1.214, 2004/07/27 11:10:47
Line 58  my $lastlog=''; Line 58  my $lastlog='';
   
 my $VERSION='$Revision$'; #' stupid emacs  my $VERSION='$Revision$'; #' stupid emacs
 my $remoteVERSION;  my $remoteVERSION;
 my $currenthostid;  my $currenthostid="default";
 my $currentdomainid;  my $currentdomainid;
   
 my $client;  my $client;
Line 1032  sub tie_user_hash { Line 1032  sub tie_user_hash {
     }      }
           
 }  }
   
   #--------------------- Request Handlers --------------------------------------------
   #
   #   By convention each request handler registers itself prior to the sub declaration:
   #
   
   #  Handles ping requests.
   #  Parameters:
   #      $cmd    - the actual keyword that invoked us.
   #      $tail   - the tail of the request that invoked us.
   #      $replyfd- File descriptor connected to the client
   #  Implicit Inputs:
   #      $currenthostid - Global variable that carries the name of the host we are
   #                       known as.
   #  Returns:
   #      1       - Ok to continue processing.
   #      0       - Program should exit.
   #  Side effects:
   #      Reply information is sent to the client.
   
   sub ping_handler {
       my ($cmd, $tail, $client) = @_;
       Debug("$cmd $tail $client .. $currenthostid:");
      
       Reply( $client,"$currenthostid\n","$cmd:$tail");
      
       return 1;
   }
   &register_handler("ping", \&ping_handler, 0, 1, 1);       # Ping unencoded, client or manager.
   
   
 #---------------------------------------------------------------  #---------------------------------------------------------------
 #  #
 #   Getting, decoding and dispatching requests:  #   Getting, decoding and dispatching requests:
Line 1096  sub process_request { Line 1127  sub process_request {
     chomp($command);      chomp($command);
     chomp($tail);      chomp($tail);
     $tail =~ s/(\r)//; # This helps people debugging with e.g. telnet.      $tail =~ s/(\r)//; # This helps people debugging with e.g. telnet.
       $command =~ s/(\r)//; # And this too for parameterless commands.
       if(!$tail) {
    $tail =""; # defined but blank.
       }
   
     &Debug("Command received: $command, encoded = $wasenc");      &Debug("Command received: $command, encoded = $wasenc");
   
Line 1140  sub process_request { Line 1175  sub process_request {
     }          }    
   
 # ------------------------------------------------------------- Normal commands  # ------------------------------------------------------------- Normal commands
 # ------------------------------------------------------------------------ ping      if ($userinput =~ /^pong/) { # client only
     if ($userinput =~ /^ping/) { # client only  
  if(isClient) {  
     print $client "$currenthostid\n";  
  } else {  
     Reply($client, "refused\n", $userinput);  
  }  
 # ------------------------------------------------------------------------ pong  
     }elsif ($userinput =~ /^pong/) { # client only  
  if(isClient) {   if(isClient) {
     my $reply=&reply("ping",$clientname);      my $reply=&reply("ping",$clientname);
     print $client "$currenthostid:$reply\n";       print $client "$currenthostid:$reply\n"; 
Line 3129  sub Debug { Line 3156  sub Debug {
 #     request - Original request from client.  #     request - Original request from client.
 #  #
 sub Reply {  sub Reply {
     alarm(120);  
     my $fd      = shift;  
     my $reply   = shift;  
     my $request = shift;  
   
     my ($fd, $reply, $request) = @_;      my ($fd, $reply, $request) = @_;
     print $fd $reply;      print $fd $reply;
     Debug("Request was $request  Reply was $reply");      Debug("Request was $request  Reply was $reply");
   
     $Transactions++;      $Transactions++;
     alarm(0);  
   
   
 }  }

Removed from v.1.213  
changed lines
  Added in v.1.214


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