[LON-CAPA-cvs] cvs: loncom / LondConnection.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 09 Feb 2004 13:33:16 -0000


albertel		Mon Feb  9 08:33:16 2004 EDT

  Modified files:              
    /loncom	LondConnection.pm 
  Log:
  -fix tabination 
  
  
Index: loncom/LondConnection.pm
diff -u loncom/LondConnection.pm:1.24 loncom/LondConnection.pm:1.25
--- loncom/LondConnection.pm:1.24	Mon Feb  9 05:57:37 2004
+++ loncom/LondConnection.pm	Mon Feb  9 08:33:16 2004
@@ -1,7 +1,7 @@
 #   This module defines and implements a class that represents
 #   a connection to a lond daemon.
 #
-# $Id: LondConnection.pm,v 1.24 2004/02/09 10:57:37 foxr Exp $
+# $Id: LondConnection.pm,v 1.25 2004/02/09 13:33:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -216,10 +216,10 @@
                      Cipher             => undef};
     bless($self, $class);
     unless ($self->{Socket} = IO::Socket::INET->new(PeerHost => $self->{Host},
-					       PeerPort => $self->{Port},
-					       Type     => SOCK_STREAM,
-					       Proto    => "tcp",
-					       Timeout  => 3)) {
+						    PeerPort => $self->{Port},
+						    Type     => SOCK_STREAM,
+						    Proto    => "tcp",
+						    Timeout  => 3)) {
 	return undef;		# Inidicates the socket could not be made.
     }
     #
@@ -309,7 +309,7 @@
 		$socket->close();
 		return -1;
 	    }
-
+	    
 	    &Debug(8," Transition out of Initialized");
 	    $self->{TransactionRequest} = $self->{TransactionReply};
 	    $self->{InformWritable}     = 1;
@@ -317,36 +317,36 @@
 	    $self->Transition("ChallengeReceived");
 	    $self->{TimeoutRemaining}   = $self->{TimeoutValue};
 	    return 0;
-   }  elsif ($self->{State} eq "ChallengeReplied") {
-      if($self->{TransactionReply} ne "ok\n") {
-         $self->Transition("Disconnected");
-         $socket->close();
-         return -1;
-      }
-      $self->Transition("RequestingVersion");
-      $self->{InformReadable}   = 0;
-      $self->{InformWritable}   = 1;
-      $self->{TransactionRequest} = "version\n";
-      return 0;
-   } elsif ($self->{State} eq "ReadingVersionString") {
-      $self->{LondVersion}       = chomp($self->{TransactionReply});
-      $self->Transition("SetHost");
-      $self->{InformReadable}    = 0;
-      $self->{InformWritable}    = 1;
-      my $peer = $self->{LoncapaHim};
-      $self->{TransactionRequest}= "sethost:$peer\n";
-      return 0;
+	}  elsif ($self->{State} eq "ChallengeReplied") {
+	    if($self->{TransactionReply} ne "ok\n") {
+		$self->Transition("Disconnected");
+		$socket->close();
+		return -1;
+	    }
+	    $self->Transition("RequestingVersion");
+	    $self->{InformReadable}   = 0;
+	    $self->{InformWritable}   = 1;
+	    $self->{TransactionRequest} = "version\n";
+	    return 0;
+	} elsif ($self->{State} eq "ReadingVersionString") {
+	    $self->{LondVersion}       = chomp($self->{TransactionReply});
+	    $self->Transition("SetHost");
+	    $self->{InformReadable}    = 0;
+	    $self->{InformWritable}    = 1;
+	    my $peer = $self->{LoncapaHim};
+	    $self->{TransactionRequest}= "sethost:$peer\n";
+	    return 0;
 	} elsif ($self->{State} eq "HostSet") { # should be ok.
-      if($self->{TransactionReply} ne "ok\n") {
-         $self->Transition("Disconnected");
-         $socket->close();
-         return -1;
-      }
-	   $self->Transition("RequestingKey");
-	   $self->{InformReadable}  = 0;
-	   $self->{InformWritable}  = 1;
-	   $self->{TransactionRequest} = "ekey\n";
-	   return 0;
+	    if($self->{TransactionReply} ne "ok\n") {
+		$self->Transition("Disconnected");
+		$socket->close();
+		return -1;
+	    }
+	    $self->Transition("RequestingKey");
+	    $self->{InformReadable}  = 0;
+	    $self->{InformWritable}  = 1;
+	    $self->{TransactionRequest} = "ekey\n";
+	    return 0;
 	} elsif ($self->{State}  eq "ReceivingKey") {
 	    my $buildkey = $self->{TransactionReply};
 	    my $key = $self->{LoncapaHim}.$perlvar{'lonHostID'};
@@ -395,7 +395,7 @@
     }
 
     return 0;
-    
+
 }
 
 
@@ -410,6 +410,7 @@
 Returns  0 if successful, or -1 if not.
 
 =cut
+
 sub Writable {
     my $self     = shift;		# Get reference to the object.
     my $socket   = $self->{Socket};
@@ -428,41 +429,41 @@
 	($errno == POSIX::EINTR)          ||
 	($errno ==  0)) {
 	substr($self->{TransactionRequest}, 0, $nwritten) = ""; # rmv written part
-      if(length $self->{TransactionRequest} == 0) {
-         $self->{InformWritable} = 0;
-         $self->{InformReadable} = 1;
-         $self->{TransactionReply} = '';
-         #
-         # Figure out the next state:
-         #
-         if($self->{State} eq "Connected") {
-            $self->Transition("Initialized");
-         } elsif($self->{State} eq "ChallengeReceived") {
-            $self->Transition("ChallengeReplied");
-         } elsif($self->{State} eq "RequestingVersion") {
-            $self->Transition("ReadingVersionString");
-         } elsif ($self->{State} eq "SetHost") {
-            $self->Transition("HostSet");
-         } elsif($self->{State} eq "RequestingKey") {
-            $self->Transition("ReceivingKey");
+	if(length $self->{TransactionRequest} == 0) {
+	    $self->{InformWritable} = 0;
+	    $self->{InformReadable} = 1;
+	    $self->{TransactionReply} = '';
+	    #
+	    # Figure out the next state:
+	    #
+	    if($self->{State} eq "Connected") {
+		$self->Transition("Initialized");
+	    } elsif($self->{State} eq "ChallengeReceived") {
+		$self->Transition("ChallengeReplied");
+	    } elsif($self->{State} eq "RequestingVersion") {
+		$self->Transition("ReadingVersionString");
+	    } elsif ($self->{State} eq "SetHost") {
+		$self->Transition("HostSet");
+	    } elsif($self->{State} eq "RequestingKey") {
+		$self->Transition("ReceivingKey");
 #            $self->{InformWritable} = 0;
 #            $self->{InformReadable} = 1;
 #            $self->{TransactionReply} = '';
-         } elsif ($self->{State} eq "SendingRequest") {
-            $self->Transition("ReceivingReply");
-            $self->{TimeoutRemaining} = $self->{TimeoutValue};
-         } elsif ($self->{State} eq "Disconnected") {
-            return -1;
-         }
-         return 0;
-      }
-   } else {			# The write failed (e.g. partner disconnected).
-      $self->Transition("Disconnected");
-      $socket->close();
-      return -1;
-   }
-	
+	    } elsif ($self->{State} eq "SendingRequest") {
+		$self->Transition("ReceivingReply");
+		$self->{TimeoutRemaining} = $self->{TimeoutValue};
+	    } elsif ($self->{State} eq "Disconnected") {
+		return -1;
+	    }
+	    return 0;
+	}
+    } else {			# The write failed (e.g. partner disconnected).
+	$self->Transition("Disconnected");
+	$socket->close();
+	return -1;
+    }
 }
+
 =pod
 
 =head2 Tick