--- loncom/loncnew 2007/03/28 20:28:29 1.81 +++ loncom/loncnew 2007/03/28 21:44:05 1.82 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # lonc maintains the connections to remote computers # -# $Id: loncnew,v 1.81 2007/03/28 20:28:29 albertel Exp $ +# $Id: loncnew,v 1.82 2007/03/28 21:44:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -94,6 +94,7 @@ my $executable = $0; # Get the full # my $RemoteHost; # Name of host child is talking to. my $RemoteHostId; # default lonid of host child is talking to. +my @all_host_ids; my $UnixSocketDir= $perlvar{'lonSockDir'}; my $IdleConnections = Stack->new(); # Set of idle connections my %ActiveConnections; # Connections to the remote lond. @@ -1161,10 +1162,7 @@ sub QueueDelayed { Debug(4, "Delayed path: ".$path); opendir(DIRHANDLE, $path); - use Apache::lonnet; - my @all_host_ids = &Apache::lonnet::machine_ids($RemoteHost); - - my $host_id_re = '(?:'.join('|',@all_host_ids).')'; + my $host_id_re = '(?:'.join('|',map {quotemeta($_)} (@all_host_ids)).')'; my @alldelayed = grep(/\.$host_id_re$/, readdir(DIRHANDLE)); closedir(DIRHANDLE); foreach my $dfname (sort(@alldelayed)) { @@ -1208,6 +1206,7 @@ sub MakeLondConnection { return 0; # Failure. } else { + $LondConnecting = 1; # Connection in progress. # The connection needs to have writability # monitored in order to send the init sequence # that starts the whole authentication/key @@ -1238,7 +1237,6 @@ sub MakeLondConnection { } Log("SUCESS", "Created connection ".$ConnectionCount ." to host ".GetServerHost()); - $LondConnecting = 1; # Connection in progress. return 1; # Return success. } @@ -1766,7 +1764,7 @@ sub CreateChild { $RemoteHost = "Parent"; $ChildHash{$pid} = $host; sigprocmask(SIG_UNBLOCK, $sigset); - + undef(@all_host_ids); } else { # child. $RemoteHostId = $hostid; ShowStatus("Connected to ".$RemoteHost); @@ -1809,37 +1807,37 @@ sub parent_client_connection { } sub get_remote_hostname { - my ($event) = @_; - my $watcher = $event->w; - my $socket = $watcher->fd; - - my $thisread; - my $rv = $socket->recv($thisread, POSIX::BUFSIZ, 0); - Debug(8, "rcv: data length = ".length($thisread)." read =".$thisread); - if (!defined($rv) || length($thisread) == 0) { - # Likely eof on socket. - Debug(5,"Client Socket closed on lonc for p_c_c"); - close($socket); - $watcher->cancel(); - return; - } + my ($event) = @_; + my $watcher = $event->w; + my $socket = $watcher->fd; - my $data = $watcher->data().$thisread; - $watcher->data($data); - if($data =~ /\n$/) { # Request entirely read. - chomp($data); - } else { - return; - } - - &Debug(5,"Creating child for $data (parent_client_connection)"); - my ($hostname,$lonid) = split(':',$data,2); - &CreateChild($hostname,$lonid); - - # Clean up the listen since now the child takes over until it exits. - $watcher->cancel(); # Nolonger listening to this event - $socket->send("done\n"); - $socket->close(); + my $thisread; + my $rv = $socket->recv($thisread, POSIX::BUFSIZ, 0); + Debug(8, "rcv: data length = ".length($thisread)." read =".$thisread); + if (!defined($rv) || length($thisread) == 0) { + # Likely eof on socket. + Debug(5,"Client Socket closed on lonc for p_c_c"); + close($socket); + $watcher->cancel(); + return; + } + + my $data = $watcher->data().$thisread; + $watcher->data($data); + if($data =~ /\n$/) { # Request entirely read. + chomp($data); + } else { + return; + } + + &Debug(5,"Creating child for $data (parent_client_connection)"); + (my $hostname,my $lonid,@all_host_ids) = split(':',$data); + &CreateChild($hostname,$lonid); + + # Clean up the listen since now the child takes over until it exits. + $watcher->cancel(); # Nolonger listening to this event + $socket->send("done\n"); + $socket->close(); } # parent_listen: