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
This commit is contained in:
Hanno Hecker 2007-09-25 06:10:23 +00:00
parent c2f006723b
commit 0be3400ede

View File

@ -373,10 +373,16 @@ sub new_child {
$qpsmtpd = $qpsmtpd_base; $qpsmtpd = $qpsmtpd_base;
# set STDIN/STDOUT and autoflush # set STDIN/STDOUT and autoflush
POSIX::dup2(fileno($client), 0) # ... no longer use POSIX::dup2: it failes after a few
|| die "unable to duplicate filehandle to STDIN - $!"; # million connections
POSIX::dup2(fileno($client), 1) close(STDIN);
|| die "unable to duplicate filehandle to STDOUT - $!"; 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; $| = 1;
# connection recieved, block signals # connection recieved, block signals