From 0be3400ede7b158ccdb8e3f5acc2b19ba6d6eb7d Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Tue, 25 Sep 2007 06:10:23 +0000 Subject: [PATCH] prefork: using POSIX::dup2 failed after a few million connections, so close and reopen STDIN (S. Priebe) git-svn-id: https://svn.perl.org/qpsmtpd/trunk@798 958fd67b-6ff1-0310-b445-bb7760255be9 --- qpsmtpd-prefork | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/qpsmtpd-prefork b/qpsmtpd-prefork index d947190..75daa17 100755 --- a/qpsmtpd-prefork +++ b/qpsmtpd-prefork @@ -373,10 +373,16 @@ sub new_child { $qpsmtpd = $qpsmtpd_base; # set STDIN/STDOUT and autoflush - POSIX::dup2(fileno($client), 0) - || die "unable to duplicate filehandle to STDIN - $!"; - POSIX::dup2(fileno($client), 1) - || die "unable to duplicate filehandle to STDOUT - $!"; + # ... no longer use POSIX::dup2: it failes after a few + # million connections + close(STDIN); + open(STDIN, "+<&".fileno($client)) + or die "unable to duplicate filehandle to STDIN - $!"; + + close(STDOUT); + open(STDOUT, "+>&".fileno($client)) + or die "unable to duplicate filehandle to STDOUT - $!"; + select(STDOUT); $| = 1; # connection recieved, block signals