[LON-CAPA-cvs] cvs: loncom / LondConnection.pm loncnew /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 27 Jan 2006 20:37:22 -0000
albertel Fri Jan 27 15:37:22 2006 EDT
Modified files:
/loncom loncnew LondConnection.pm
/loncom/lonnet/perl lonnet.pm
Log:
- connections are now be hostname not lon machine id
- socket files are by hostname
- lonnet.pm prepends sethost:<lonid>: to each command
- LondConnection takes care of tracking with machine id the lond thinks it
- it strips the sethost command if it's unneeded
- it splits it into two seperate commands that it sends in order
if lond needs to be told
- eventually for lond of late enoyugh heritage it will just
send the whole command
Index: loncom/loncnew
diff -u loncom/loncnew:1.73 loncom/loncnew:1.74
--- loncom/loncnew:1.73 Fri Jan 27 11:35:13 2006
+++ loncom/loncnew Fri Jan 27 15:37:12 2006
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# lonc maintains the connections to remote computers
#
-# $Id: loncnew,v 1.73 2006/01/27 16:35:13 albertel Exp $
+# $Id: loncnew,v 1.74 2006/01/27 20:37:12 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1875,7 +1875,7 @@
my $host_iterator = &LondConnection::GetHostIterator();
while (!$host_iterator->end()) {
my $host_entry_ref = $host_iterator->get();
- my $host_name = $host_entry_ref->[0];
+ my $host_name = $host_entry_ref->[3];
Debug(9, "Listen for $host_name");
&parent_listen($host_name);
$host_iterator->next();
Index: loncom/LondConnection.pm
diff -u loncom/LondConnection.pm:1.38 loncom/LondConnection.pm:1.39
--- loncom/LondConnection.pm:1.38 Thu Jan 26 16:34:25 2006
+++ loncom/LondConnection.pm Fri Jan 27 15:37:12 2006
@@ -1,7 +1,7 @@
# This module defines and implements a class that represents
# a connection to a lond daemon.
#
-# $Id: LondConnection.pm,v 1.38 2006/01/26 21:34:25 albertel Exp $
+# $Id: LondConnection.pm,v 1.39 2006/01/27 20:37:12 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -213,14 +213,13 @@
=cut
sub new {
-
- my ($class, $Hostname, $Port) = @_;
+ my ($class, $DnsName, $Port) = @_;
if (!$ConfigRead) {
ReadConfig();
$ConfigRead = 1;
}
- &Debug(4,$class."::new( ".$Hostname.",".$Port.")\n");
+ &Debug(4,$class."::new( ".$DnsName.",".$Port.")\n");
# The host must map to an entry in the hosts table:
# We connect to the dns host that corresponds to that
@@ -228,12 +227,12 @@
# negotion. In the objec these become the Host and
# LoncapaHim fields of the object respectively.
#
- if (!exists $hostshash{$Hostname}) {
- &Debug(8, "No Such host $Hostname");
+ if (!exists $hostshash{$DnsName}) {
+ &Debug(8, "No Such host $DnsName");
return undef; # No such host!!!
}
- my @ConfigLine = @{$hostshash{$Hostname}};
- my $DnsName = $ConfigLine[3]; # 4'th item is dns of host.
+ my @ConfigLine = @{$hostshash{$DnsName}};
+ my $Hostname = $ConfigLine[0]; # 0'th item is the msu id of host.
Debug(5, "Connecting to ".$DnsName);
# if it is me use loopback for connection
if ($DnsName eq $LocalDns) { $DnsName="127.0.0.1"; }
@@ -246,6 +245,7 @@
AuthenticationMode => "",
TransactionRequest => "",
TransactionReply => "",
+ NextRequest => "",
InformReadable => 0,
InformWritable => 0,
TimeoutCallback => undef,
@@ -562,11 +562,23 @@
$answer = $self->Decrypt($answer);
$self->{TransactionReply} = "$answer\n";
}
-
+ # if we have a NextRequest do it immeadiately
+ if ($self->{NextRequest}) {
+ $self->{TransactionRequest} = $self->{NextRequest};
+ undef( $self->{NextRequest} );
+ $self->{TransactionReply} = "";
+ $self->{InformWritable} = 1;
+ $self->{InformReadable} = 0;
+ $self->{Timeoutable} = 1;
+ $self->{TimeoutRemaining} = $self->{TimeoutValue};
+ $self->Transition("SendingRequest");
+ return 0;
+ } else {
# finish the transaction
- $self->ToIdle();
- return 0;
+ $self->ToIdle();
+ return 0;
+ }
} elsif ($self->{State} eq "Disconnected") { # No connection.
return -1;
} else { # Internal error: Invalid state.
@@ -718,14 +730,25 @@
return -1; # Error indicator.
}
# if the transaction is to be encrypted encrypt the data:
+ (my $sethost, my $server,$data)=split(/:/,$data,3);
if($data =~ /^encrypt\:/) {
$data = $self->Encrypt($data);
}
# Setup the trasaction
-
- $self->{TransactionRequest} = $data;
+ # currently no version of lond supports inlining the sethost
+ if ($self->PeerVersion() <= 10000000) {
+ if ($server ne $self->{LoncapaHim}) {
+ $self->{NextRequest} = $data;
+ $self->{TransactionRequest} = "$sethost:$server\n";
+ $self->{LoncapaHim} = $server;
+ } else {
+ $self->{TransactionRequest} = $data;
+ }
+ } else {
+ $self->{TransactionRequest} = "$sethost:$server:$data";
+ }
$self->{TransactionReply} = "";
$self->{InformWritable} = 1;
$self->{InformReadable} = 0;
@@ -1217,7 +1240,7 @@
{
my @list = @items; # probably not needed but I'm unsure of
# about the scope of item so...
- $HostsTab{$list[0]} = \@list;
+ $HostsTab{$list[3]} = \@list;
}
}
}
@@ -1234,7 +1257,7 @@
#
sub PeerVersion {
my $self = shift;
-
+ my ($version) = ($self->{LondVersion} =~ /Revision 1\.(\d+)/);
return $self->{LondVersion};
}
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.703 loncom/lonnet/perl/lonnet.pm:1.704
--- loncom/lonnet/perl/lonnet.pm:1.703 Thu Jan 26 02:14:39 2006
+++ loncom/lonnet/perl/lonnet.pm Fri Jan 27 15:37:21 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.703 2006/01/26 07:14:39 albertel Exp $
+# $Id: lonnet.pm,v 1.704 2006/01/27 20:37:21 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -124,7 +124,7 @@
# -------------------------------------------------- Non-critical communication
sub subreply {
my ($cmd,$server)=@_;
- my $peerfile="$perlvar{'lonSockDir'}/$server";
+ my $peerfile="$perlvar{'lonSockDir'}/".$hostname{$server};
#
# With loncnew process trimming, there's a timing hole between lonc server
# process exit and the master server picking up the listen on the AF_UNIX
@@ -152,7 +152,7 @@
}
my $answer;
if ($client) {
- print $client "$cmd\n";
+ print $client "sethost:$server:$cmd\n";
$answer=<$client>;
if (!$answer) { $answer="con_lost"; }
chomp($answer);