[pmg-devel] [PATCH pmg-api 01/12] refactor reload_rule_db

Stoiko Ivanov s.ivanov at proxmox.com
Mon Oct 7 21:28:45 CEST 2019


move the reload of pmg-smtp-filter in a sub in PMG::Utils and call it in
the only place it was used (PMG::DBTools::reload_rule_db).

This is in preparation for fixing #2371 and dkim-signing support.

Additionally an unneeded import was removed from PMG/DBTools.pm

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 src/PMG/DBTools.pm | 11 +----------
 src/PMG/Utils.pm   | 13 +++++++++++++
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/PMG/DBTools.pm b/src/PMG/DBTools.pm
index c675e2f..4483f2e 100644
--- a/src/PMG/DBTools.pm
+++ b/src/PMG/DBTools.pm
@@ -11,7 +11,6 @@ use Time::Local;
 use PVE::SafeSyslog;
 use PVE::Tools;
 
-use PMG::Utils;
 use PMG::RuleDB;
 use PMG::MailQueue;
 use PMG::Config;
@@ -1259,15 +1258,7 @@ sub reload_ruledb {
 	}
     }
 
-    my $pid_file = '/run/pmg-smtp-filter.pid';
-    my $pid = PVE::Tools::file_read_firstline($pid_file);
-
-    return 0 if !$pid;
-
-    return 0 if $pid !~ m/^(\d+)$/;
-    $pid = $1; # untaint
-
-    return kill (10, $pid); # send SIGUSR1
+    PMG::Utils::reload_smtp_filter();
 }
 
 1;
diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index 2dc22ad..ad031f8 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -1429,4 +1429,17 @@ sub get_pg_server_version {
     return $major_ver;
 }
 
+sub reload_smtp_filter {
+
+    my $pid_file = '/run/pmg-smtp-filter.pid';
+    my $pid = PVE::Tools::file_read_firstline($pid_file);
+
+    return 0 if !$pid;
+
+    return 0 if $pid !~ m/^(\d+)$/;
+    $pid = $1; # untaint
+
+    return kill (10, $pid); # send SIGUSR1
+}
+
 1;
-- 
2.20.1




More information about the pmg-devel mailing list