X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXProt.pm;h=d6ea691796e82c3078f04d8aa1c41cc6e4c50b5e;hb=874ee7e39c3d38f5b52226ced9486af33a7505c4;hp=c26016ee5048ce9205175a484ae042c3be8b1b31;hpb=aa8cc0d19a7ad2cc5d8891187ceae2fba73eee2d;p=spider.git diff --git a/perl/DXProt.pm b/perl/DXProt.pm index c26016ee..d6ea6917 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -1039,14 +1039,28 @@ sub normal $dxchan->send($dxchan->msg('pingi', $from, $s, $ave)) } elsif ($dxchan->is_node) { if ($tochan) { - $tochan->{nopings} = $tochan->user->nopings || 2; # pump up the timer + my $nopings = $tochan->user->nopings || 2; push @{$tochan->{pingtime}}, $t; shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6; - my $st; - for (@{$tochan->{pingtime}}) { - $st += $_; + + # cope with a missed ping, this means you must set the pingint large enough + my $miss = ($nopings-$tochan->{nopings}+1) * $tochan->{pingint}; + if ($tochan->is_arcluster && $miss > 0 && $t > $miss && $t < $miss + $tochan->{nopings} ) { + $t -= $miss; + } + + # calc smoothed RTT a la TCP + if (@{$tochan->{pingtime}} == 1) { + $tochan->{pingave} = $t; + } else { + $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 8); } - $tochan->{pingave} = $st / @{$tochan->{pingtime}}; +# my $st; +# for (@{$tochan->{pingtime}}) { +# $st += $_; +# } +# $tochan->{pingave} = $st / @{$tochan->{pingtime}}; + $tochan->{nopings} = $nopings; # pump up the timer } } }