Commit d23235d0 authored by Robert Ricci's avatar Robert Ricci

Handle counters that wrap around.

parent 34cfcc2d
......@@ -245,7 +245,17 @@ foreach my $name (keys %portMap) {
my %oldvals = $dbresult->fetchhash();
for (my $i = 0; $i < @oids; $i++) {
if ($oldvals{$oids[$i]}) {
$result->[$i] -= $oldvals{$oids[$i]};
#
# Check for wraparound - of course, we can't tell
# how many times it wrapped, but we can at least
# not print a negative number.
# XXX - we harcode the size of the counter here
#
if ($result->[$i] >= $oldvals{$oids[$i]}) {
$result->[$i] -= $oldvals{$oids[$i]};
} else {
$result->[$i] += (2**32 - $oldvals{$oids[$i]});
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment