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;
# 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