qmail-queue: a few tweaks and a lot of whitespace
This commit is contained in:
parent
52b5227cd5
commit
e69893a961
@ -20,6 +20,11 @@ If set the environment variable QMAILQUEUE overrides this setting.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Qpsmtpd::Constants;
|
||||
use POSIX ();
|
||||
|
||||
sub register {
|
||||
@ -27,12 +32,10 @@ sub register {
|
||||
|
||||
if (@args > 0) {
|
||||
$self->{_queue_exec} = $args[0];
|
||||
$self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if (@args > 1);
|
||||
}
|
||||
else {
|
||||
$self->{_queue_exec} = ($ENV{QMAIL} || '/var/qmail') . "/bin/qmail-queue";
|
||||
$self->log(LOGWARN, "WARNING: Ignoring additional arguments.") if @args > 1;
|
||||
}
|
||||
|
||||
$self->{_queue_exec} ||= ($ENV{QMAIL} || '/var/qmail') . "/bin/qmail-queue";
|
||||
$self->{_queue_exec} = $ENV{QMAILQUEUE} if $ENV{QMAILQUEUE};
|
||||
}
|
||||
|
||||
@ -40,22 +43,22 @@ sub hook_queue {
|
||||
my ($self, $transaction) = @_;
|
||||
|
||||
# these bits inspired by Peter Samuels "qmail-queue wrapper"
|
||||
pipe(MESSAGE_READER, MESSAGE_WRITER) or die("Could not create message pipe");
|
||||
pipe(ENVELOPE_READER, ENVELOPE_WRITER) or die("Could not create envelope pipe");
|
||||
pipe(MESSAGE_READER, MESSAGE_WRITER) or die "Could not create message pipe";
|
||||
pipe(ENVELOPE_READER, ENVELOPE_WRITER) or die "Could not create envelope pipe";
|
||||
|
||||
local $SIG{PIPE} = sub { die "SIGPIPE" };
|
||||
local $SIG{PIPE} = sub { die 'SIGPIPE' };
|
||||
my $child = fork();
|
||||
|
||||
not defined $child and die("Could not fork");
|
||||
! defined $child and die "Could not fork";
|
||||
|
||||
if ($child) {
|
||||
# Parent
|
||||
my $oldfh = select(MESSAGE_WRITER); $| = 1;
|
||||
select(ENVELOPE_WRITER); $| = 1;
|
||||
select($oldfh);
|
||||
my $oldfh = select MESSAGE_WRITER; $| = 1;
|
||||
select ENVELOPE_WRITER; $| = 1;
|
||||
select $oldfh;
|
||||
|
||||
close MESSAGE_READER or die("close msg reader fault");
|
||||
close ENVELOPE_READER or die("close envelope reader fault");
|
||||
close MESSAGE_READER or die "close msg reader fault";
|
||||
close ENVELOPE_READER or die "close envelope reader fault";
|
||||
|
||||
$transaction->header->print(\*MESSAGE_WRITER);
|
||||
$transaction->body_resetpos;
|
||||
@ -102,7 +105,7 @@ sub hook_queue {
|
||||
POSIX::dup2(fileno(ENVELOPE_READER), 1) or die "Unable to dup ENVELOPE_READER: $!";
|
||||
|
||||
my $ppid = getppid();
|
||||
$self->log(LOGNOTICE, "(for $ppid ) Queuing qp $$ to $queue_exec");
|
||||
$self->log(LOGNOTICE, "(for $ppid) Queuing to $queue_exec");
|
||||
|
||||
my $rc = exec $queue_exec;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user