[pmg-devel] [PATCH pmg-api v4 01/11] refactor reload_rule_db
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Oct 21 19:23:25 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 66dfc28..a7a18a4 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;
@@ -1276,15 +1275,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 11d8f5c..6f114f2 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