From 52f149e76f3f98025d2377e36ef4a77eb369cd73 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 15 Jun 2011 18:36:22 +0000 Subject: [PATCH] -Move XML formatting from plugin worker process to parent, allowing worker to get back to working faster while parent concurrently does XML stuff git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9808 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/sbin/xcatd | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index af30e2d3a..a72011813 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -1396,11 +1396,13 @@ sub convey_response { build_response($resp); return; } - $resp = XMLout($resp,KeyAttr=>[], NoAttr=>1,RootName=>'xcatresponse'); + $resp = freeze($resp); + #$resp = XMLout($resp,KeyAttr=>[], NoAttr=>1,RootName=>'xcatresponse'); #sanitize the response, to avoid being killed by non-printable bytes - $resp =~ tr/\011-\177/?/c; + #$resp =~ tr/\011-\177/?/c; #seeing if using utf-8 offloads potential issues to client terminal, it didn't print $parent_fd $resp; + print $parent_fd "\nENDOFFREEZE6sK6xa\n"; yield; #parent must get timeslice anyway before an ack could possibly return my $parsel = new IO::Select; $parsel->add($parent_fd); @@ -1654,22 +1656,31 @@ sub relay_fds { #Relays file descriptors from pipes to children to the SSL socke my $text; foreach $rfh (@readyset) { #go through each child, extract a complete, atomic message my $line; + my $resp; while ($line = <$rfh>) { #Will break on complete messages, avoid interleave - eval { - print $sock $line; - }; + $resp .= $line; + if ($line =~ /ENDOFFREEZE6sK6xa\n/) { + print $rfh "nfin\n"; #ok, ack the data (superfluous, but svn revision history shows an oddity with killed processes and assuming that was legit... for now) + #ack before doing the real work to allow child to get back to work + $resp = thaw($resp); + $resp = XMLout($resp,KeyAttr=>[], NoAttr=>1,RootName=>'xcatresponse'); + #sanitize the response, to avoid being killed by non-printable bytes + $resp =~ tr/\011-\177/?/c; + #seeing if using utf-8 offloads potential issues to client terminal, it didn't + eval { + print $sock $resp; + }; + last; + } if ($@ and $@ =~ /PIPE/) { $goneclient=1; print "Piped while writing to client\n"; last; } - if ($line =~ /<\/xcatresponse>/) { - last; - } } - if ($line) { - print $rfh "nfin\n"; #Notify convey_response message done - } else { + unless ($line) { +# print $rfh "nfin\n"; #Notify convey_response message done +# } else { $fds->remove($rfh); close($rfh); }