Skip to content
This repository
Browse code

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
  • Loading branch information...
commit f0b31cbb9be44f8a9a9fcb9df8816b3cf6ddbfb5 1 parent 11da7e2
authored July 12, 2005

Showing 1 changed file with 2 additions and 6 deletions. Show diff stats Hide diff stats

  1. 8  plugins/queue/qmail-queue
8  plugins/queue/qmail-queue
@@ -41,7 +41,8 @@ sub hook_queue {
41 41
   # these bits inspired by Peter Samuels "qmail-queue wrapper"
42 42
   pipe(MESSAGE_READER, MESSAGE_WRITER) or die("Could not create message pipe");
43 43
   pipe(ENVELOPE_READER, ENVELOPE_WRITER) or die("Could not create envelope pipe");
44  
-
  44
+  
  45
+  local $SIG{PIPE} = sub { die "SIGPIPE" };
45 46
   my $child = fork();
46 47
 
47 48
   not defined $child and die("Could not fork");
@@ -55,10 +56,6 @@ sub hook_queue {
55 56
     close MESSAGE_READER  or die("close msg reader fault");
56 57
     close ENVELOPE_READER or die("close envelope reader fault");
57 58
 
58  
-    # Note - technically there's a race here because if the exec() below
59  
-    # fails and the writes to MESSAGE_WRITER block we get a deadlocked process.
60  
-    # This check to see if(eof(PIPE)) will catch "most" of these problems.
61  
-    die "Message pipe has been closed" if eof(MESSAGE_WRITER);
62 59
     $transaction->header->print(\*MESSAGE_WRITER);
63 60
     $transaction->body_resetpos;
64 61
     while (my $line = $transaction->body_getline) {
@@ -68,7 +65,6 @@ sub hook_queue {
68 65
 
69 66
     my @rcpt = map { "T" . $_->address } $transaction->recipients;
70 67
     my $from = "F".($transaction->sender->address|| "" );
71  
-    die "Envelope pipe has been closed" if eof(ENVELOPE_WRITER);
72 68
     print ENVELOPE_WRITER "$from\0", join("\0",@rcpt), "\0\0"
73 69
       or return(DECLINED,"Could not print addresses to queue");
74 70
     

0 notes on commit f0b31cb

Please sign in to comment.
Something went wrong with that request. Please try again.