Switch xCAT server connection to client back toblocking IO for large segments of code depending on blocking io

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@12725 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2012-05-15 19:45:01 +00:00
parent 786c0b9a20
commit 413b5ce1f6

View File

@ -1701,20 +1701,23 @@ sub service_connection {
my $request;
my $req=undef;
my $line;
my $flags=fcntl($sock,F_GETFL,0);
$flags |= O_NONBLOCK; #we want sysread to bail on us, select seems to be evil to us still..
fcntl($sock,F_SETFL,$flags);
my $clientsel = new IO::Select;
$clientsel->add($sock);
while (1) {
$line="";
unless ($clientsel->can_read(15)) { last; } #don't let an unresponsive client hold us up
my $flags=fcntl($sock,F_GETFL,0);
$flags |= O_NONBLOCK; #we want sysread to bail on us, select seems to be evil to us still..
fcntl($sock,F_SETFL,$flags);
my $bytesread;
do { $bytesread=sysread($sock,$line,65536,length($line)) } while ($bytesread);
if (length($line)==0) {
if (not defined $bytesread and $! == EAGAIN) { next; } #
last;
}
my $flags=fcntl($sock,F_GETFL,0);
$flags &= ~O_NONBLOCK; #now we want *print* to be blocking IO
fcntl($sock,F_SETFL,$flags);
$request .= $line;
#$req = eval { XMLin($request, ForceArray => [ 'attribute' , 'attributepair' ]) };
if ($line =~ m/<\/xcatrequest>/) {