aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/LXRng/ModPerl.pm9
-rw-r--r--lib/LXRng/Web.pm15
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/LXRng/ModPerl.pm b/lib/LXRng/ModPerl.pm
index 60bb1c7..1e1cd95 100644
--- a/lib/LXRng/ModPerl.pm
+++ b/lib/LXRng/ModPerl.pm
@@ -23,6 +23,7 @@ use strict;
use LXRng;
use LXRng::Web;
+use Time::HiRes qw(time);
use Apache2::Const -compile => qw(FORBIDDEN OK);
use CGI;
@@ -31,14 +32,14 @@ use Data::Dumper;
sub handler {
my ($req) = @_;
- my @tstart = times();
+ my @tstart = (time+0, times());
my $query = CGI->new();
my $qident = LXRng::Web->handle($query);
- my @tstop = times();
+ my @tstop = (time+0, times());
$req->notes->add("lxr_prof" =>
- sprintf("U/S/CU/CS: %d/%d/%d/%d ms",
- map { 1000*($tstop[$_]-$tstart[$_]) } (0 .. 3)));
+ sprintf("T/U/S/CU/CS: %d/%d/%d/%d/%d ms",
+ map { 1000*($tstop[$_]-$tstart[$_]) } (0 .. 4)));
$req->notes->add("lxr_ident" => $qident);
return Apache2::Const::OK;
diff --git a/lib/LXRng/Web.pm b/lib/LXRng/Web.pm
index e616170..28a3f3a 100644
--- a/lib/LXRng/Web.pm
+++ b/lib/LXRng/Web.pm
@@ -765,18 +765,20 @@ sub generate_pdf {
'lines' => \@lines},
$texh)
or die $template->error();
- my $pid = fork();
- die $! unless defined($pid);
+
+ my $pdflatex;
+ my $pid = open($pdflatex, "-|");
+ die $! unless defined $pid;
+
if ($pid == 0) {
- close(STDOUT);
- open(STDOUT, "> $texname.output");
close(STDERR);
open(STDERR, ">&STDOUT");
chdir($tempdir);
exec("pdflatex", "$texname");
kill(9, $$);
}
- waitpid($pid, 0);
+ my @err = <$pdflatex>;
+ close($pdflatex);
my $pdfname = $texname;
$pdfname =~ s/[.]tex$/.pdf/;
if (-e $pdfname) {
@@ -792,9 +794,6 @@ sub generate_pdf {
close($pdfh);
}
elsif (-e "$texname.output") {
- open(my $errh, "< $texname.output") or die $!;
- my @err = <$errh>;
- close($errh);
@err = splice(@err, -15) if @err > 15;
die "PDF generation failed: ".join("\n", @err);
}