MERGE 498:499 FROM https://svn.perl.org/qpsmtpd/trunk
Better fix for pipe being closed bug git-svn-id: https://svn.perl.org/qpsmtpd/branches/0.31@500 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
11da7e2778
commit
f0b31cbb9b
@ -42,6 +42,7 @@ sub hook_queue {
|
|||||||
pipe(MESSAGE_READER, MESSAGE_WRITER) or die("Could not create message 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");
|
pipe(ENVELOPE_READER, ENVELOPE_WRITER) or die("Could not create envelope pipe");
|
||||||
|
|
||||||
|
local $SIG{PIPE} = sub { die "SIGPIPE" };
|
||||||
my $child = fork();
|
my $child = fork();
|
||||||
|
|
||||||
not defined $child and die("Could not fork");
|
not defined $child and die("Could not fork");
|
||||||
@ -55,10 +56,6 @@ sub hook_queue {
|
|||||||
close MESSAGE_READER or die("close msg reader fault");
|
close MESSAGE_READER or die("close msg reader fault");
|
||||||
close ENVELOPE_READER or die("close envelope reader fault");
|
close ENVELOPE_READER or die("close envelope reader fault");
|
||||||
|
|
||||||
# Note - technically there's a race here because if the exec() below
|
|
||||||
# fails and the writes to MESSAGE_WRITER block we get a deadlocked process.
|
|
||||||
# This check to see if(eof(PIPE)) will catch "most" of these problems.
|
|
||||||
die "Message pipe has been closed" if eof(MESSAGE_WRITER);
|
|
||||||
$transaction->header->print(\*MESSAGE_WRITER);
|
$transaction->header->print(\*MESSAGE_WRITER);
|
||||||
$transaction->body_resetpos;
|
$transaction->body_resetpos;
|
||||||
while (my $line = $transaction->body_getline) {
|
while (my $line = $transaction->body_getline) {
|
||||||
@ -68,7 +65,6 @@ sub hook_queue {
|
|||||||
|
|
||||||
my @rcpt = map { "T" . $_->address } $transaction->recipients;
|
my @rcpt = map { "T" . $_->address } $transaction->recipients;
|
||||||
my $from = "F".($transaction->sender->address|| "" );
|
my $from = "F".($transaction->sender->address|| "" );
|
||||||
die "Envelope pipe has been closed" if eof(ENVELOPE_WRITER);
|
|
||||||
print ENVELOPE_WRITER "$from\0", join("\0",@rcpt), "\0\0"
|
print ENVELOPE_WRITER "$from\0", join("\0",@rcpt), "\0\0"
|
||||||
or return(DECLINED,"Could not print addresses to queue");
|
or return(DECLINED,"Could not print addresses to queue");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user