Bug 122560 - Call _cleanup even on code errors

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1781 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2013-09-05 16:03:14 +00:00
parent 5e044c7ee1
commit 3f9cd0a799
1 changed files with 6 additions and 1 deletions

View File

@ -205,15 +205,20 @@ sub handle_request
my $start = [gettimeofday];
$in_eval = 1;
eval { &{$subs{$script}}(); };
my $err;
if ($@ && (!ref($@) || ref($@) ne 'Bugzilla::HTTPServerSimple::FakeExit'))
{
return $self->print_error(500, 'Internal Server Error', "Error while running $script:\n$@");
$err = "Error while running $script:\n$@";
}
eval { Bugzilla::_cleanup(); };
if ($@ && (!ref($@) || ref($@) ne 'Bugzilla::HTTPServerSimple::FakeExit'))
{
warn "Error in _cleanup():\n$@";
}
if ($err)
{
return $self->print_error(500, 'Internal Server Error', $err);
}
$in_eval = 0;
my $elapsed = tv_interval($start) * 1000;
print STDERR strftime("[%Y-%m-%d %H:%M:%S]", localtime)." Served $script in $elapsed ms\n";