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