diff --git a/cbp/modules/Quotas.pm b/cbp/modules/Quotas.pm index 0d4794c4eef15a4c1b370bee792af5d7f55461bf..ca2feacb8305ca57d43a0cb75c8accf306728a08 100644 --- a/cbp/modules/Quotas.pm +++ b/cbp/modules/Quotas.pm @@ -21,7 +21,7 @@ package cbp::modules::Quotas; use strict; use warnings; - +use Time::HiRes; use cbp::logging; use awitpt::db::dblayer; @@ -94,7 +94,7 @@ sub check { # Our verdict and data my ($verdict,$verdict_data); - my $now = time(); + my $now = Time::HiRes::time; # @@ -178,7 +178,7 @@ POLICY: foreach my $priority (sort {$a <=> $b} keys %{$sessionData->{'Policy'}} # Calculate the % of the period we have, and multiply it with the counter ... this should give us a reasonably # accurate counting } else { - $currentCounter = ( 1 - ($elapsedTime / $quota->{'Period'}) ) * $qtrack->{'Counter'}; + $currentCounter = ( 1.0 - ($elapsedTime / $quota->{'Period'}) ) * $qtrack->{'Counter'}; } # Work out the difference to the DB value, we ONLY DO THIS ONCE!!! so if its defined, leave it alone! @@ -196,7 +196,7 @@ POLICY: foreach my $priority (sort {$a <=> $b} keys %{$sessionData->{'Policy'}} $hasExceeded = "Policy rejection; Message count quota exceeded"; } # Bump up limit - $newCounters{$qtrack->{'QuotasLimitsID'}}++; + $newCounters{$qtrack->{'QuotasLimitsID'}} += 1.0; # Check for cumulative size violation } elsif ($limitType eq "messagecumulativesize") { @@ -220,7 +220,7 @@ POLICY: foreach my $priority (sort {$a <=> $b} keys %{$sessionData->{'Policy'}} # Check if this is a message counter if (lc($limit->{'Type'}) eq "messagecount") { # Bump up limit - $newCounters{$qtrack->{'QuotasLimitsID'}}++; + $newCounters{$qtrack->{'QuotasLimitsID'}} += 1.0; } } diff --git a/database/quotas.tsql b/database/quotas.tsql index 076fedd08f72dc44b73b0464f6330b737de11dad..baa97e109fb27fb1ac0924022afcb6c385bbcfaa 100644 --- a/database/quotas.tsql +++ b/database/quotas.tsql @@ -79,7 +79,7 @@ CREATE TABLE @PREFIX@quotas_tracking ( TrackKey VARCHAR(@TRACK_KEY_LEN@), /* Last time this record was update */ - LastUpdate @BIG_INTEGER_UNSIGNED@, /* NULL means not updated yet */ + LastUpdate NUMERIC(10,4), /* NULL means not updated yet */ Counter NUMERIC(10,4),