--- projects/cms/source/host/ihost-perl/ihost.pl 2001/03/16 18:25:59 1.32 +++ projects/cms/source/host/ihost-perl/ihost.pl 2001/11/14 14:17:12 1.35 @@ -9,8 +9,8 @@ # methods as you see fit. # - pjm2@ukc.ac.uk # -# $Author: pjm2 $ -# $Id: ihost.pl,v 1.32 2001/03/16 18:25:59 pjm2 Exp $ +# $Author: tdb $ +# $Id: ihost.pl,v 1.35 2001/11/14 14:17:12 tdb Exp $ #------------------------------------------------------------ $| = 1; @@ -45,7 +45,7 @@ $filter_manager_addr = $ARGV[0]; $filter_manager_port = $ARGV[1]; $seq_no = 1; -$retry_wait = 6; +$retry_wait = 60; # write our PID to a file $pidfile = "/var/tmp/ihost.pid"; @@ -75,7 +75,7 @@ while (1) { else { $delay = $next_tcp; } - `sleep $delay`; + sleep $delay; } # we'll probably never get here... @@ -90,7 +90,7 @@ exit(0); #----------------------------------------------------------------------- sub wait_then_retry() { print "Will retry configuration with filter manager in $retry_wait seconds.\n"; - `sleep $retry_wait`; + sleep $retry_wait; } @@ -283,7 +283,8 @@ sub send_udp_packet() { } $disk_info .= ""; - my($ip) = inet_ntoa(scalar(gethostbyname(hostname())) || 'localhost'); + my($ip); + $ip = inet_ntoa(scalar(gethostbyname(hostname())) || 'localhost') or $ip = 'localhost'; # Build the XML packet this way, as we can clearly # see the structure and contents... I like this ;-) @@ -360,9 +361,13 @@ EOF # send_tcp_heartbeat # Establishes a TCP connection to an i-scream filter. # The heartbeat is used as a guaranteed "I'm alive" delivery mechanism. +# If we need to reconfigure, then we complete the heartbeat before +# doing so. #----------------------------------------------------------------------- sub send_tcp_heartbeat() { + my ($doReconfigure) = 0; + my($sock) = new IO::Socket::INET( PeerAddr => $filter_addr, PeerPort => $tcp_port, @@ -409,8 +414,7 @@ sub send_tcp_heartbeat() { if ($response eq "ERROR\n") { close($sock); print "Server configuration changed. Reconfiguring with filter manager.\n"; - &tcp_configure(); - return; + $doReconfigure = 1; } if (!$response eq "OK\n") { close($sock); @@ -430,6 +434,8 @@ sub send_tcp_heartbeat() { close($sock); print "^"; + + &tcp_configure() if $doReconfigure; return; }