48 |
|
$last_udp_time = time; |
49 |
|
$last_tcp_time = time; |
50 |
|
while (1) { |
51 |
< |
if (time >= $last_udp_time + $udp_update_time) { |
51 |
> |
my($time) = time; |
52 |
> |
if ($time >= $last_udp_time + $udp_update_time) { |
53 |
|
&send_udp_packet(); |
54 |
< |
$last_udp_time = time; |
54 |
> |
$last_udp_time = $time; |
55 |
|
} |
56 |
< |
if (time >= $last_tcp_time + $tcp_update_time) { |
56 |
> |
if ($time >= $last_tcp_time + $tcp_update_time) { |
57 |
|
&send_tcp_heartbeat(); |
58 |
< |
$last_tcp_time = time; |
58 |
> |
$last_tcp_time = $time; |
59 |
|
} |
60 |
< |
`sleep 1`; |
60 |
> |
my($next_udp) = $udp_update_time - $time + $last_udp_time; |
61 |
> |
my($next_tcp) = $tcp_update_time - $time + $last_tcp_time; |
62 |
> |
my($delay); |
63 |
> |
if ($next_udp < $next_tcp) { |
64 |
> |
$delay = $next_udp |
65 |
> |
} |
66 |
> |
else { |
67 |
> |
$delay = $next_tcp; |
68 |
> |
} |
69 |
> |
`sleep $delay`; |
70 |
|
} |
71 |
|
|
72 |
|
exit(0); |
180 |
|
|
181 |
|
my($hostname) = hostname(); |
182 |
|
$hostname =~ s/\..*$//g; |
183 |
< |
my($domainname) = `cat /etc/resolv.conf`; |
184 |
< |
$domainname =~ /domain\s+([^\s]+)/; |
175 |
< |
$domainname = $1; |
183 |
> |
`cat /etc/resolv.conf` =~ /domain\s+([^\s]+)/; |
184 |
> |
my($domainname) = $1; |
185 |
|
my($machine_name) = "$hostname.$domainname"; |
186 |
|
my($ip) = inet_ntoa(scalar(gethostbyname($hostname)) || 'localhost'); |
187 |
|
|