diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index a2e6cd70e..d869b51ab 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -846,21 +846,22 @@ my $tconn; until ($quit) { $SIG{CHLD} = \&ssl_reaper; #set here to ensure that signal handler is not corrupted during loop if (@pendingconnections) { - while ($listenwatcher->can_read(0)) { #grab everything we ca + while ($listenwatcher->can_read(0)) { #grab everything we can, but don't spend any time waiting for more $tconn = $listener->accept; - unless ($tconn) { next; } + unless ($tconn) { next; } push @pendingconnections,$tconn; } } else { - $tconn = $listener->accept; - unless ($tconn) { next; } + $tconn = $listener->accept; #we have no connections pending, no rush, just wait until the next connection attempt comes in + unless ($tconn) { next; } #sometimes we get 'undef', in which case carry on with our lives... push @pendingconnections,$tconn; } - unless (scalar @pendingconnections) { next; } - if ($sslclients > $maxsslclients) { #THROTTLE + unless (scalar @pendingconnections) { next; } #if for some reason we landed here without any accepted connections, carry on.. + if ($sslclients > $maxsslclients) { #we have enough children, wait for some to exit before spawning more $listenwatcher->can_read(0.1); #when next connection tries to come in or a tenth of a second, whichever comes first next; #just keep pulling things off listen queue onto our own } + #we have a pending connection and we are under the threshold, grab one from the list and process it... my $cnnection=shift @pendingconnections; my $connection; my $child = xCAT::Utils->xfork(); #Yes we fork, IO::Socket::SSL is not threadsafe..