[LON-CAPA-cvs] cvs: newloncapa / loncnew
foxr
lon-capa-cvs@mail.lon-capa.org
Thu, 03 Apr 2003 02:40:22 -0000
foxr Wed Apr 2 21:40:22 2003 EDT
Modified files:
/newloncapa loncnew
Log:
Verify that multiple transactions work properly.
Index: newloncapa/loncnew
diff -u newloncapa/loncnew:1.4 newloncapa/loncnew:1.5
--- newloncapa/loncnew:1.4 Tue Apr 1 18:22:01 2003
+++ newloncapa/loncnew Wed Apr 2 21:40:22 2003
@@ -35,8 +35,9 @@
#
my $IdleConnections = Stack->new();
-my %ActiveConnections;
-my %ActiveTransactions;
+my %ActiveConnections; # Connections to the remote lond.
+my %ActiveTransactions; # Transactions in flight.
+my %ActiveClients; # Set of local clients (by Socket).
my $WorkQueue = Queue->new(); # Queue of pending transactions.
@@ -90,6 +91,7 @@
sub Tick {
Debug(4, "Tick");
+ Debug(9, " Current connection count: ".$ConnectionCount);
}
=pod
@@ -182,9 +184,12 @@
#
# Set up to read next request from socket:
+ my @info = @ActiveClients{$Socket};
+ my $descr = sprintf("Connection to lonc client %d",
+ $info[1]);
Event->io(cb => \&ClientRequest,
poll => 'r',
- desc => "Connection to lonc client",
+ desc => $descr,
data => "",
fd => $Socket);
@@ -232,8 +237,13 @@
my $data = $Socket->GetReply(); # Data to send.
&Debug(8," Reply was: ".$data);
+ my @ClientInfo = @ActiveClients{$Client};
+ my $Serial = $ClientInfo[1];
+ my $desc = sprintf("Connection to lonc client %d",
+ $Serial);
Event->io(fd => $Client,
poll => "w",
+ desc => $desc,
cb => \&ClientWritable,
data => $data);
}
@@ -520,6 +530,7 @@
&Debug(4,"MakeLondConnection got socket: ".$Socket);
}
+
$event = Event->io(fd => $Socket,
poll => 'w',
cb => \&LondWritable,
@@ -527,7 +538,8 @@
desc => 'Connection to lond server');
$ActiveConnections{$Lond} = $event;
-
+ $ConnectionCount++;
+
}
=pod
@@ -589,7 +601,7 @@
Debug(4,"Must queue...");
$ClientQueue->enqueue($requestSocket);
$WorkQueue->enqueue($requestData);
- if($ConnectionCount < $MaxConneciontCount) {
+ if($ConnectionCount < $MaxConnectionCount) {
Debug(4,"Starting additional lond connection");
MakeLondConnection();
}
@@ -625,6 +637,7 @@
Debug(2,"Socket closed");
close($socket);
$watcher->cancel();
+ delete(@ActiveClients{$socket});
}
Debug(8,"Data: ".$data." this read: ".$thisread);
$data = $data.$thisread; # Append new data.
@@ -664,6 +677,7 @@
desc => $description,
data => "",
fd => $connection);
+ @ActiveClients{$connection} = ($Connection, $ClientConnection);
$ClientConnection++;
}
=pod GetLoncSocketPath