From: minima Date: Mon, 28 May 2001 17:50:29 +0000 (+0000) Subject: try to prevent the lack of a peer address causing the cluster to crash X-Git-Tag: OLDROUTE_1_48~10 X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=commitdiff_plain;h=28830bd907c3f7192605ad4aa6c818feb2394e70 try to prevent the lack of a peer address causing the cluster to crash --- diff --git a/perl/ExtMsg.pm b/perl/ExtMsg.pm index 74c544c4..07d77cba 100644 --- a/perl/ExtMsg.pm +++ b/perl/ExtMsg.pm @@ -129,28 +129,35 @@ sub new_client { $conn->{sock} = $sock; Msg::blocking($sock, 0); $conn->{blocking} = 0; - - my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport()); - dbg('connll', "accept $conn->{cnum} from $conn->{peerhost} $conn->{peerport}"); - if ($eproc) { - $conn->{eproc} = $eproc; - Msg::set_event_handler ($sock, "error" => $eproc); - } - if ($rproc) { - $conn->{rproc} = $rproc; - my $callback = sub {$conn->_rcv}; - Msg::set_event_handler ($sock, "read" => $callback); - # send login prompt - $conn->{state} = 'WL'; - # $conn->send_raw("\xff\xfe\x01\xff\xfc\x01\ff\fd\x22"); - # $conn->send_raw("\xff\xfa\x22\x01\x01\xff\xf0"); - # $conn->send_raw("\xFF\xFC\x01"); - $conn->_send_file("$main::data/issue"); - $conn->send_raw("login: "); - $conn->_dotimeout(60); - } else { - &{$conn->{eproc}}() if $conn->{eproc}; - $conn->disconnect(); + my $host; + eval {$host = $conn->{peerhost}}; + my $port; + eval {$port = $conn->{peerport}} unless $@; + if ($@) { + $conn->disconnect; + } else { + my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $host, $conn->{peerport} = $port); + dbg('connll', "accept $conn->{cnum} from $conn->{peerhost} $conn->{peerport}"); + if ($eproc) { + $conn->{eproc} = $eproc; + Msg::set_event_handler ($sock, "error" => $eproc); + } + if ($rproc) { + $conn->{rproc} = $rproc; + my $callback = sub {$conn->_rcv}; + Msg::set_event_handler ($sock, "read" => $callback); + # send login prompt + $conn->{state} = 'WL'; + # $conn->send_raw("\xff\xfe\x01\xff\xfc\x01\ff\fd\x22"); + # $conn->send_raw("\xff\xfa\x22\x01\x01\xff\xf0"); + # $conn->send_raw("\xFF\xFC\x01"); + $conn->_send_file("$main::data/issue"); + $conn->send_raw("login: "); + $conn->_dotimeout(60); + } else { + &{$conn->{eproc}}() if $conn->{eproc}; + $conn->disconnect(); + } } } else { dbg('err', "ExtMsg: error on accept ($!)");