diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2017-06-01 11:00:58 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2017-06-01 11:00:58 +0200 |
commit | 8cfd584400a9852c4bd7c4b3d50ff0cacc8ec019 (patch) | |
tree | 81850b8f211b095c149bb24c334a4608323c87e6 /roles/MSA/files/usr | |
parent | 63bca29310bc899ce6c7068f376cbfb426da3571 (diff) |
postfix-sender-login: terminate the worker after 32*$nProc connections to release ressources.
Diffstat (limited to 'roles/MSA/files/usr')
-rwxr-xr-x | roles/MSA/files/usr/local/bin/postfix-sender-login.pl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/roles/MSA/files/usr/local/bin/postfix-sender-login.pl b/roles/MSA/files/usr/local/bin/postfix-sender-login.pl index 5f563c3..e792457 100755 --- a/roles/MSA/files/usr/local/bin/postfix-sender-login.pl +++ b/roles/MSA/files/usr/local/bin/postfix-sender-login.pl @@ -49,20 +49,25 @@ die "This service must be socket-activated.\n" and defined $ENV{LISTEN_FDS} and $ENV{LISTEN_FDS} == 1; open my $S, '+<&=', 3 or die "fdopen: $!"; +my @CHILDREN; for (my $i = 0; $i < $nProc-1; $i++) { my $pid = fork() // die "fork: $!"; - unless ($pid) { + if ($pid) { + push @CHILDREN, $pid; + } else { server(); # child, never return exit; } } server(); +waitpid $_ => 0 foreach @CHILDREN; +exit $?; ############################################################################# sub server() { - while(1) { + for (my $n = 0; $n < 32; $n++) { accept(my $conn, $S) or do { next if $! == EINTR; die "accept: $!"; |