summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2020-08-25 15:23:19 +0200
committerAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2020-08-25 15:23:19 +0200
commitb27431c79bfb6d6284e6079b9c1104a44af24775 (patch)
tree041b2fdb8eac6f2d4b1b0ad5b956f1eaeda3cea6
parent78349ac1769a48e5047e6cb0e29e528d5a02dfbd (diff)
downloaddmarc-b27431c79bfb6d6284e6079b9c1104a44af24775.tar.gz
dmarc-b27431c79bfb6d6284e6079b9c1104a44af24775.tar.bz2
dmarc-b27431c79bfb6d6284e6079b9c1104a44af24775.zip
Use prefork Sendmail::PMilter
-rwxr-xr-xdmarc_milter.pl37
1 files changed, 23 insertions, 14 deletions
diff --git a/dmarc_milter.pl b/dmarc_milter.pl
index 67e463f..ba638d5 100755
--- a/dmarc_milter.pl
+++ b/dmarc_milter.pl
@@ -11,7 +11,7 @@ use Find::Lib '.';
use Getopt::Long;
use Pod::Usage;
-use Sendmail::Milter;
+use Sendmail::PMilter;
use Spline::DMARC qw(check_addresses);
use Spline::Data;
use Spline::Log qw(set_verbose set_stderr debug info);
@@ -21,10 +21,13 @@ use Spline::Log qw(set_verbose set_stderr debug info);
# the milter interface.
sub main($listen, $mailman, $message) {
- Sendmail::Milter::setconn($listen);
+ my $milter = new Sendmail::PMilter;
+
+ umask(0002);
+ $milter->setconn($listen);
# Setup the callbacks
- Sendmail::Milter::register('dmarc_milter', {
+ $milter->register('dmarc_milter', {
'envfrom' => sub($ctx, $from, @) {
# We only need this callback to initialize the private
# data and the logging context.
@@ -32,7 +35,7 @@ sub main($listen, $mailman, $message) {
$data->set('counter', 0);
debug "MAIL FROM: $from";
- return SMFIS_CONTINUE;
+ return Sendmail::PMilter::SMFIS_CONTINUE;
},
'envrcpt' => sub($ctx, $rcpt_to, @) {
@@ -45,7 +48,7 @@ sub main($listen, $mailman, $message) {
$data->set('counter', 1);
}
- return SMFIS_CONTINUE;
+ return Sendmail::PMilter::SMFIS_CONTINUE;
},
'header' => sub($ctx, $name, $value) {
@@ -53,7 +56,7 @@ sub main($listen, $mailman, $message) {
# If there was no Mailinglist address, we can simply
# accept this mail and skip all following callbacks
- return SMFIS_ACCEPT if $data->get('counter') == 0;
+ return Sendmail::PMilter::SMFIS_ACCEPT if $data->get('counter') == 0;
debug "HEADER '$name': $value";
if (lc($name) eq 'from') {
@@ -64,11 +67,11 @@ sub main($listen, $mailman, $message) {
# REJECT here. No more callbacks, are called for
# this message.
- return SMFIS_REJECT;
+ return Sendmail::PMilter::SMFIS_REJECT;
}
}
- return SMFIS_CONTINUE;
+ return Sendmail::PMilter::SMFIS_CONTINUE;
},
'eoh' => sub($ctx) {
@@ -78,24 +81,30 @@ sub main($listen, $mailman, $message) {
# If we did not reject this message during the headers, we
# can now accept it and do not call anymore callbacks for
# this message.
- return SMFIS_ACCEPT;
+ return Sendmail::PMilter::SMFIS_ACCEPT;
},
'close' => sub($ctx) {
- Spline::Data->load($ctx);
+ my $data = Spline::Data->load($ctx);
+ return Sendmail::PMilter::SMFIS_CONTINUE unless defined $data->get('counter');
# Free the connection-private memory.
$ctx->setpriv(undef);
debug 'CLOSE';
- return SMFIS_CONTINUE;
+ return Sendmail::PMilter::SMFIS_CONTINUE;
},
});
+ # Use prefork dispatcher (should be faster then the default
+ # postfork variant)
+ $milter->set_dispatcher(Sendmail::PMilter::prefork_dispatcher(
+ "max_children" => 30,
+ "max_requests_per_child" => 100,
+ ));
+
# Start the mainloop:
- # No interpreter limit, but recycle after 100 requests
- umask(0002);
- Sendmail::Milter::main(0, 100);
+ $milter->main();
}
my $help;