From bd4af1093f3c5704c99379c7538cb6fd62f732f6 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 23 Mar 2012 12:55:35 +0000 Subject: [PATCH] Have xCAT more aggressively drain the listen queue on the main listening socket. This change manages to have xCAT successfully field a large amount of incoming connections with a relatively small listen queue. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@11962 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/sbin/xcatd | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 23c05a148..a2e6cd70e 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -823,6 +823,7 @@ while (not $listener and $retry) { } sleep(0.05); } +my $listenwatcher = IO::Select->new($listener); unless ($listener) { kill 2, $pid_UDP; @@ -840,13 +841,28 @@ open($mainpidfile,">","/tmp/xcat/mainservice.pid"); #if here, everyone else has print $mainpidfile $$; close($mainpidfile); closelog(); +my @pendingconnections; +my $tconn; until ($quit) { $SIG{CHLD} = \&ssl_reaper; #set here to ensure that signal handler is not corrupted during loop - next unless my $cnnection=$listener->accept; - my $connection; - while ($sslclients > $maxsslclients) { #THROTTLE - sleep 0.1; #Keep processor utilization down + if (@pendingconnections) { + while ($listenwatcher->can_read(0)) { #grab everything we ca + $tconn = $listener->accept; + unless ($tconn) { next; } + push @pendingconnections,$tconn; + } + } else { + $tconn = $listener->accept; + unless ($tconn) { next; } + push @pendingconnections,$tconn; } + unless (scalar @pendingconnections) { next; } + if ($sslclients > $maxsslclients) { #THROTTLE + $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 + } + my $cnnection=shift @pendingconnections; + my $connection; my $child = xCAT::Utils->xfork(); #Yes we fork, IO::Socket::SSL is not threadsafe.. if ($child) { $immediatechildren{$child}=1;