[pmg-devel] [PATCH pmg-api v2 2/4] pmg-smtp-filter: cleanup use of gettimeofday
Stoiko Ivanov
s.ivanov at proxmox.com
Fri Jan 12 20:21:49 CET 2024
in preparation for handling a processing timeout and passing the
startime to apply_rules, just unify the different syntax we use
throught the file.
no semantic change intended.
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/bin/pmg-smtp-filter | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/bin/pmg-smtp-filter b/src/bin/pmg-smtp-filter
index 7da3de8..ba4e58e 100755
--- a/src/bin/pmg-smtp-filter
+++ b/src/bin/pmg-smtp-filter
@@ -524,7 +524,7 @@ sub run_dequeue {
$self->log (2, "starting database maintenance");
- my ($csec, $usec) = gettimeofday ();
+ my $starttime = [ gettimeofday() ];
my $cinfo = PVE::INotify::read_file("cluster.conf");
@@ -540,8 +540,7 @@ sub run_dequeue {
if ($err) {
$self->log (0, $err);
} else {
- my ($csec_end, $usec_end) = gettimeofday ();
- my $ptime = int (($csec_end - $csec) * 1000 + ($usec_end - $usec) / 1000);
+ my $ptime = int(tv_interval($starttime) * 1000);
$self->log (2, "end database maintenance ($ptime ms)");
}
@@ -560,7 +559,7 @@ sub unpack_entity {
if (PMG::Unpack::is_archive ($magic)) {
$self->log (3, "$queue->{logid}: found archive '$filename' ($magic)");
- my $start = [gettimeofday];
+ my $start = [ gettimeofday() ];
$unpack->{mime} = {};
@@ -591,7 +590,7 @@ sub unpack_entity {
sub handle_smtp {
my ($self, $smtp) = @_;
- my ($csec, $usec) = gettimeofday ();
+ my $starttime = [ gettimeofday() ];
my $queue;
my $msginfo = {};
@@ -714,7 +713,7 @@ sub handle_smtp {
my $decdir = $queue->{dumpdir} . "/__decoded_archives";
mkdir $decdir;
- my $start = [gettimeofday];
+ my $start = [ gettimeofday() ];
my $unpack;
eval {
@@ -769,9 +768,7 @@ sub handle_smtp {
die $err if $err;
- my ($csec_end, $usec_end) = gettimeofday ();
- my $time_total =
- int (($csec_end-$csec)*1000 + ($usec_end - $usec)/1000);
+ my $time_total = int(tv_interval($starttime) * 1000);
# PHASE 5 - log statistics
# on error: log error messages
--
2.39.2
More information about the pmg-devel
mailing list