--- loncom/loncnew	2006/01/27 16:35:13	1.73
+++ loncom/loncnew	2006/08/25 21:12:19	1.76
@@ -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.76 2006/08/25 21:12:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -198,7 +198,7 @@ sub Log {
     my $now   = time;
     my $local = localtime($now);
     my $finalformat = "$local ($$) [$RemoteHost] [$Status] ";
-    my $finalformat = $finalformat.$format."\n";
+    $finalformat = $finalformat.$format."\n";
 
     # open the file and put the result.
 
@@ -1164,19 +1164,28 @@ sub QueueDelayed {
 
     Debug(4, "Delayed path: ".$path);
     opendir(DIRHANDLE, $path);
-    
-    my @alldelayed = grep /\.$RemoteHost$/, readdir DIRHANDLE;
+
+    my @all_host_ids;
+    my $host_iterator =   &LondConnection::GetHostIterator();
+    while (!$host_iterator->end()) {
+	my ($host_id,$host_name) = @{$host_iterator->get()}[0,3];
+	if ($host_name eq $RemoteHost) {
+	    push(@all_host_ids, $host_id);
+	}
+	$host_iterator->next();
+    }
+    my $host_id_re = '(?:'.join('|',@all_host_ids).')';
+    my @alldelayed = grep(/\.$host_id_re$/, readdir(DIRHANDLE));
     closedir(DIRHANDLE);
-    my $dfname;
-    my $reqfile;
-    foreach $dfname (sort  @alldelayed) {
-	$reqfile = "$path/$dfname";
-	Debug(4, "queueing ".$reqfile);
+    foreach my $dfname (sort(@alldelayed)) {
+	my $reqfile = "$path/$dfname";
+	my ($host_id) = ($dfname =~ /\.([^.]*)$/);
+	Debug(4, "queueing ".$reqfile." for $host_id");
 	my $Handle = IO::File->new($reqfile);
 	my $cmd    = <$Handle>;
 	chomp $cmd;		# There may or may not be a newline...
 	$cmd = $cmd."\n";	# now for sure there's exactly one newline.
-	my $Transaction = LondTransaction->new($cmd);
+	my $Transaction = LondTransaction->new("sethost:$host_id:$cmd");
 	$Transaction->SetDeferred($reqfile);
 	QueueTransaction($Transaction);
     }
@@ -1722,7 +1731,7 @@ sub ChildProcess {
 	      desc => 'Lonc Listener Unix Socket',
 	      fd   => $socket);
     
-    $Event::Debuglevel = $DebugLevel;
+    $Event::DebugLevel = $DebugLevel;
     
     Debug(9, "Making initial lond connection for ".$RemoteHost);
 
@@ -1875,7 +1884,7 @@ sub listen_on_all_unix_sockets {
     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();