--- loncom/xml/run.pm 2003/03/24 22:43:31 1.32
+++ loncom/xml/run.pm 2003/06/09 21:37:54 1.37
@@ -1,6 +1,6 @@
package Apache::run;
#
-# $Id: run.pm,v 1.32 2003/03/24 22:43:31 albertel Exp $
+# $Id: run.pm,v 1.37 2003/06/09 21:37:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,6 +38,7 @@ ENDEVALUATE
sub evaluate {
my ($expression,$safeeval,$decls) = @_;
+ &Apache::lonxml::debug("got $expression and decls $decls");
unless (defined($expression)) { return ''; }
if ($Apache::lonxml::evaluate < 1) { return $expression; }
my $result = '';
@@ -45,16 +46,18 @@ sub evaluate {
$Apache::run::timeout=0;
$main::SIG{'ALRM'} = sub {
$Apache::run::timeout=1;
- Apache->request->print("timeout
\n");
+ die("timeout");
};
+ my $innererror;
eval {
- alarm(Apache->request->server->timeout);
+ alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
$safeeval->reval('{'.$decls.';$_=<<\'EXPRESSION\';'."\n".$expression.
"\n".'EXPRESSION'."\n".$EVALUATE_STRING.'}');
+ $innererror=$@;
alarm(0);
};
my $error=$@;
- if ($error eq '' && !$Apache::run::timeout) {
+ if ($error eq '' && $innererror eq '' && !$Apache::run::timeout) {
$result = $safeeval->reval('return $_;');
chomp $result;
} else {
@@ -62,9 +65,14 @@ sub evaluate {
$error = 'Code ran too long. It ran for more than '.
Apache->request->server->timeout.' seconds';
}
- &Apache::lonxml::error('substitution on
'.$expression. - 'with
'.$decls. - 'caused
'.$error); + &Apache::lonxml::error('substitution on'. + &HTML::Entities::encode($expression). + 'with'. + &HTML::Entities::encode($decls). + 'caused'. + &HTML::Entities::encode($error).' '. + &HTML::Entities::encode($innererror). + ''); } return $result } @@ -76,20 +84,23 @@ sub run { $Apache::run::timeout=0; $main::SIG{'ALRM'} = sub { $Apache::run::timeout=1; - Apache->request->print("timeout
\n"); + die("timeout"); }; + my $innererror; eval { - alarm(Apache->request->server->timeout); + alarm($Apache::lonnet::perlvar{'lonScriptTimeout'}); @result=$safeeval->reval($code); + $innererror=$@; alarm(0); }; my $error=$@; - if (($Apache::run::timeout || $error ne '') && !$hideerrors) { + if (($Apache::run::timeout || $error ne '' || $innererror ne '') && !$hideerrors) { if ($Apache::run::timeout) { $error = 'Code ran too long. It ran for more than '. Apache->request->server->timeout.' seconds'; } - &Apache::lonxml::error(''.&HTML::Entities::encode($error). + &Apache::lonxml::error(''.&HTML::Entities::encode($error).' '. + &HTML::Entities::encode($innererror). 'occured while running'. &HTML::Entities::encode($code).''); }