[prev in list] [next in list] [prev in thread] [next in thread] 

List:       amavis-tech
Subject:    [AMaViS-tech] [patch] bug in AMaViS 0.3.12pre8 (and earlier AMaViS releases)
From:       Ask Bjoern Hansen <ask () develooper ! com>
Date:       2002-09-01 21:57:09
[Download RAW message or body]

Hi,

Without the attached patch amavis 0.3.12pre8 hangs when trying to
send a long list of recipients to the real qmail-queue.


 - ask

-- 
ask bjoern hansen, http://www.askbjoernhansen.com/ !try; do();

["qmail-queue.queue.patch" (TEXT/PLAIN)]

--- qmail-queue.pl	Sun Sep  1 23:31:31 2002
+++ qmail-queue.pl.ask	Sun Sep  1 23:49:05 2002
@@ -436,83 +436,89 @@
 
 
 
-
-
-
-
-
-
-
-
-
     if ($scanner_errors) {
 	do_log(0,"All virus scanners failed!");
 	do_exit($REGERR, __LINE__);
     }
 }
 
+sub fault {
+  do_exit($REGERR, join " ", @_);
+}
+
+#
 # Forward original message
 sub forward_mail {
-    my $seen_xheader = ( $X_HEADER eq "yes" ? 0 : 1 );
+	my $seen_xheader = 0;
+	$seen_xheader = 1 if ($X_HEADER eq "no");
 
     if ($TESTING ne "yes") {
     
+	  do_log(1, "queueing mail...");
+	
 	# sending mail, qmail version
 	# In the case of qmail, we pass the original data back to
 	# qmail-queue-real.  It reads the email on descriptor 0, and the
 	# envelope on descriptor 1.
 
-	my $pipe1 = new IO::Pipe;
-	my $pipe2 = new IO::Pipe;
+	pipe(MESSAGE_READER, MESSAGE_WRITER) or do_exit($REGERR, __LINE__);
+    pipe(ENVELOPE_READER, ENVELOPE_WRITER) or do_exit($REGERR, __LINE__);
 
-	my $pid;
-	if ($pid = fork()) { # Parent
-		$pipe1->writer;
-		$pipe2->writer;
+	  my $child = fork();
+  
+	  not defined $child and do_exit($REGERR, __LINE__ . " could not fork");
+
+  if ($child) {
+    # Parent
+    my $oldfh = select(MESSAGE_WRITER); $| = 1; 
+                select(ENVELOPE_WRITER); $| = 1;
+    select($oldfh);
+
+    close MESSAGE_READER  or fault("close msg reader fault");
+    close ENVELOPE_READER or fault("close envelope reader fault");
 
-		print $pipe1 "$recipline\n";
 		while (<$fh>) {
 			next if ($seen_xheader == 0 && m/^$X_HEADER_TAG:/o);
 			if ($seen_xheader == 0 && m/\A\r?\n\Z/) {
-				print $pipe2 "$X_HEADER_TAG: $X_HEADER_LINE\n";
+		print MESSAGE_WRITER "$X_HEADER_TAG: " . "$X_HEADER_LINE\n";
 				$seen_xheader = 1;
 			}
-			print $pipe2 $_;
+	  print MESSAGE_WRITER $_;
 		}
 
-		close($pipe1);
-		close($pipe2);
+    close MESSAGE_WRITER;
 
-		if (waitpid($pid, 0) == -1) {
-			do_exit($REGERR, __LINE__);
-		} else {
-			# Pass up qmail-queue-real's error code
-			do_exit(retcode($?), __LINE__);
+    my @rcpt = map { "T" . $_ } @RECIPS;
+#	$SENDER = "" if $SENDER eq "<>";
+    my $from = "F".($SENDER|| "");
+    print ENVELOPE_WRITER "$from\0", join("\0",@rcpt), "\0\0"
+      or fault("Could not print addresses to queue");
+    
+    close ENVELOPE_WRITER;
+    waitpid($child, 0);
+    my $exit_code = $? >> 8;
+    $exit_code and fault("Unable to queue message ($exit_code)");
+	do_exit($exit_code, "queue result...");
 		}
-	} elsif (defined $pid) { # Child
-		$pipe1->reader;
-		$pipe2->reader;
-
-		close(STDOUT);
-		fcntl($pipe1, F_DUPFD, 1);
-		close($pipe1);
-
-		close(STDIN);
-		fcntl($pipe2, F_DUPFD, 0);
-		close($pipe2);
+  elsif (defined $child) {
+    # Child
+    close MESSAGE_WRITER or die "could not close message writer in parent";
+    close ENVELOPE_WRITER or die "could not close envelope writer in parent";
 
-		exec("$QMAILDIR/qmail-queue-real") || do_exit($REGERR, __LINE__);
-	} else {
-		# fork failed
-		do_exit($REGERR, __LINE__);
+    open(STDIN, "<&MESSAGE_READER") or die "b1";
+    open(STDOUT, "<&ENVELOPE_READER") or die "b2";
+    
+    unless (exec("$QMAILDIR/qmail-queue-real")) {
+      die "should never be here!";
 	}
-	# End qmail
-    } else {
+  }
+	}
+	else {
 	# print complete msg to stdout
 	while (<$fh>) {
 	    next if ($seen_xheader == 0 && m/^$X_HEADER_TAG:/o);
 	    if ($seen_xheader == 0 && m/\A\r?\n\Z/) {
-		print "$X_HEADER_TAG: $X_HEADER_LINE\n";
+				print "$X_HEADER_TAG" . ": " . "$X_HEADER_LINE\n";
 		$seen_xheader = 1;
 	    }
 	    print $_;

-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
AMaViS-tech mailing list
AMaViS-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-tech

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic