From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3CB1DC0E63 for ; Fri, 12 Jan 2024 20:22:21 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1ABE53608A for ; Fri, 12 Jan 2024 20:22:21 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 12 Jan 2024 20:22:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 461384912C for ; Fri, 12 Jan 2024 20:22:19 +0100 (CET) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Fri, 12 Jan 2024 20:21:49 +0100 Message-Id: <20240112192151.40998-4-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112192151.40998-1-s.ivanov@proxmox.com> References: <20240112192151.40998-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.088 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pmg-devel] [PATCH pmg-api v2 2/4] pmg-smtp-filter: cleanup use of gettimeofday X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2024 19:22:21 -0000 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 --- 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