Commit 36b8a791 authored by Leigh B Stoller's avatar Leigh B Stoller

Changes to allow CreateSliver() to return after the Redeem, but before

the Start. The wrapper looks at the return value to see if it is a
forked child.

Most of the change is really in libaudit with the addition of an
AuditFork that switched to a new log file.
parent 1a7562d0
......@@ -432,7 +432,6 @@ sub CreateSliver($)
# At this point we want to return and let the startsliver proceed
# in the background
#
if (0) {
my $mypid = fork();
if ($mypid) {
# Let the child get going.
......@@ -442,7 +441,6 @@ sub CreateSliver($)
}
# This switches the file that we are writing to.
libaudit::AuditFork();
}
# Make sure that the next phase sees all changes.
Experiment->FlushAll();
......
#!/usr/bin/perl -w
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2010 University of Utah and the Flux Group.
# Copyright (c) 2008-2011 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -316,6 +316,8 @@ $message .=
"Method: $method\n";
$message .=
"Version: $GENI_VERSION\n" if (defined($GENI_VERSION));
$message .=
"Start: " . TBTimeStamp() . "\n";
my $starttime = [gettimeofday()];
eval { $result = &{ $GENI_METHODS->{$method} }(@{ $call->{'value'} }) };
......@@ -333,47 +335,63 @@ if ($@) {
}
else {
my $elapsed = tv_interval($starttime);
$message .= "End: " . TBTimeStamp() . "\n";
$message .= "Elapsed: " . sprintf("%f", $elapsed) . "\n";
if (GeniResponse::IsError($result)) {
$message .= "Error: " . $result->{'code'} . "\n";
if (!ref($result)) {
$message .= "Return: $result\n";
}
else {
$message .= "Code: " . $result->{'code'} . "\n";
}
$message .= "Output: " . $result->{'output'} . "\n"
if (defined($result->{'output'}));
if (GeniResponse::IsError($result)) {
$message .= "Error: " . $result->{'code'} . "\n";
}
else {
$message .= "Code: " . $result->{'code'} . "\n";
}
$message .= "Output: " . $result->{'output'} . "\n"
if (defined($result->{'output'}));
$message .= "Result:\n" . Dumper($result->{'value'}) . "\n\n";
$message .= "Result:\n" . Dumper($result->{'value'}) . "\n\n";
}
$message .= "Request:\n" . $request . "\n";
AddAuditInfo("message", $message);
#
# If the response indicates error, and no output is defined in
# the response, then send back the contents of the audit file.
# Not sure this makes any sense at all yet, but the point is to
# get more info back to the user.
#
if (GeniResponse::IsError($result) &&
(!defined($result->{'output'}) || $result->{'output'} eq "") &&
exists($ENV{'TBAUDITLOG'}) && -s $ENV{'TBAUDITLOG'}) {
$result->{'output'} = `cat $ENV{'TBAUDITLOG'}`;
}
# Do this after above so that silly comment is not sent to user.
if (GeniResponse::IsError($result) && $mailerrors &&
$result->{'code'} != GENIRESPONSE_SEARCHFAILED()) {
print STDERR "Mail Errors is on.\n";
}
#
# Added this for geni-am ...
#
if (defined($GENI_RESPONSE_CONVERTER)) {
$response = &$GENI_RESPONSE_CONVERTER($result);
if (! ref($result)) {
#
# This could happen if the child forks.
#
if ($result) {
print STDERR "Child forked but returned an error\n";
}
}
else {
$response = $decoder->encode_response($result);
#
# If the response indicates error, and no output is defined in
# the response, then send back the contents of the audit file.
# Not sure this makes any sense at all yet, but the point is to
# get more info back to the user.
#
if (GeniResponse::IsError($result) &&
(!defined($result->{'output'}) || $result->{'output'} eq "") &&
exists($ENV{'TBAUDITLOG'}) && -s $ENV{'TBAUDITLOG'}) {
$result->{'output'} = `cat $ENV{'TBAUDITLOG'}`;
}
# Do this after above so that silly comment is not sent to user.
if (GeniResponse::IsError($result) && $mailerrors &&
$result->{'code'} != GENIRESPONSE_SEARCHFAILED()) {
print STDERR "Mail Errors is on.\n";
}
#
# Added this for geni-am ...
#
if (defined($GENI_RESPONSE_CONVERTER)) {
$response = &$GENI_RESPONSE_CONVERTER($result);
}
else {
$response = $decoder->encode_response($result);
}
}
}
......@@ -387,7 +405,8 @@ if ($debug) {
#
LogEnd(0);
print "Content-Type: text/xml \n\n" . $response;
print "Content-Type: text/xml \n\n" . $response
if (defined($response));
exit(0);
#
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -298,8 +298,36 @@ sub AuditAbort()
#
sub AuditFork()
{
$auditing = 0;
delete @ENV{'TBAUDITLOG', 'TBAUDITON'};
return 0
if (!$auditing || !defined($logfile));
$logfile = TBMakeLogname("$SCRIPTNAME");
$ENV{'TBAUDITLOG'} = $logfile;
# Need to close these so that this side of the fork is disconnected.
if (!$daemon && $PERL_VERSION >= 5.008) {
close($libaudit::SAVE_STDOUT);
close($libaudit::SAVE_STDERR);
}
close(STDOUT);
close(STDERR);
open(STDOUT, ">> $logfile") or
die("opening $logfile for STDOUT: $!");
open(STDERR, ">> $logfile") or
die("opening $logfile for STDERR: $!");
#
# Turn off line buffering on output
#
STDOUT->autoflush(1);
STDERR->autoflush(1);
#
# Create a new session to ensure we are clear of any process group.
#
POSIX::setsid();
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment