Reduce memory usage of xCAT by about 66%

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11616 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2012-02-18 19:34:57 +00:00
parent 4a5773f139
commit b460198863

View File

@ -569,6 +569,7 @@ sleep 0.05;
sub scan_plugins {
my $serialdest = shift;
my @plugins=glob($plugins_dir."/*.pm");
foreach (@plugins) {
/.*\/([^\/]*).pm$/;
@ -606,8 +607,36 @@ sub scan_plugins {
}
${"xCAT_plugin::".$modname."::"}{init_plugin}->(\&do_request);
}
if ($serialdest) { print $serialdest freeze(\%cmd_handlers); };
}
scan_plugins;
my $pid_init;
my $readpipe;
my $writepipe;
if (socketpair($readpipe, $writepipe,AF_UNIX,SOCK_STREAM,PF_UNSPEC)) {
$pid_init = xCAT::Utils->xfork;
} else {
xCAT::MsgUtils->message("S", "socketpair failed: $!");
}
if (defined $pid_init) {
if ($pid_init) { #parent, just sit and wait..
close($writepipe);
my $serialized_handlers;
while ($serialized_handlers !~ /xCATINITDoneWithHandlersNow/) {
$serialized_handlers.=<$readpipe>;
}
%cmd_handlers=%{thaw($serialized_handlers)};
} else {
scan_plugins($writepipe);
print $writepipe "\nxCATINITDoneWithHandlersNow\n";
exit(0);
}
} else {
print "Unable to branch the initialization portion, will use more memory\n";
scan_plugins();
}
unless (xCAT::Utils->isLinux()) { # messes up the output of the service cmd on linux
eval {
xCAT::MsgUtils->message("S","xCATd: service starting");