--- loncom/loncnew 2007/03/27 19:38:36 1.77 +++ loncom/loncnew 2007/03/28 00:05:38 1.78 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # lonc maintains the connections to remote computers # -# $Id: loncnew,v 1.77 2007/03/27 19:38:36 albertel Exp $ +# $Id: loncnew,v 1.78 2007/03/28 00:05:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1529,15 +1529,14 @@ another event handler to subess requests =cut sub SetupLoncListener { + my ($host,$SocketName) = @_; + if (!$host) { $host = &GetServerHost(); } + if (!$SocketName) { $SocketName = &GetLoncSocketPath($host); } - my $host = GetServerHost(); # Default host. - if (@_) { - ($host) = @_ # Override host with parameter. - } - my $socket; - my $SocketName = GetLoncSocketPath($host); unlink($SocketName); + + my $socket; unless ($socket =IO::Socket::UNIX->new(Local => $SocketName, Listen => 250, Type => SOCK_STREAM)) { @@ -1844,7 +1843,7 @@ sub get_remote_hostname { my $socket = $watcher->fd; my $thisread; - my $rv = $socket->recv($thisread, 1, 0); + 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. @@ -1890,13 +1889,21 @@ sub parent_listen { my ($loncapa_host) = @_; Debug(5, "parent_listen: $loncapa_host"); - my $socket = &SetupLoncListener($loncapa_host); + my ($socket,$file); + if (!$loncapa_host) { + $loncapa_host = 'common_parent'; + $file = $perlvar{'lonSockCreate'}; + } else { + $file = &GetLoncSocketPath($loncapa_host); + } + $socket = &SetupLoncListener($loncapa_host,$file); + $listening_to{$socket} = $loncapa_host; if (!$socket) { die "Unable to create a listen socket for $loncapa_host"; } - my $lock_file = &GetLoncSocketPath($loncapa_host).".lock"; + my $lock_file = $file.".lock"; unlink($lock_file); # No problem if it doesn't exist yet [startup e.g.] my $watcher = @@ -1950,7 +1957,7 @@ sub listen_on_all_unix_sockets { sub listen_on_common_socket { Debug(5, "listen_on_common_socket"); - &parent_listen('common'); + &parent_listen(); } # server_died is called whenever a child process exits.