From 5cf51f98b63e969d09c4a0d21dbadc18961e6af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20J=2E=20G=2E=20Burzy=C5=84ski?= Date: Sun, 6 May 2012 00:00:02 +0100 Subject: [PATCH] log outside of eval --- lib/App/livehttperf.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/App/livehttperf.pm b/lib/App/livehttperf.pm index b2b03e4..b6ff77b 100644 --- a/lib/App/livehttperf.pm +++ b/lib/App/livehttperf.pm @@ -399,20 +399,21 @@ sub run_tests { eval { $res = $ua->request($req, $OPTS{verbosity} == 1 ? sub { print "." } : () ) or die "No response\n"; - - LOG "[$tid.$no.$rec_no] RES:\n", $res->headers->as_string if DEBUG; - LOG "[$tid.$no.$rec_no] RES:\n", $res->as_string if TRACE; }; + my $err = $@; push @{ $rec_stats_data{$rec_no} }, tv_interval( $rec_stats_start ); if ( $res ) { + LOG "[$tid.$no.$rec_no] RES:\n", $res->headers->as_string if DEBUG; + LOG "[$tid.$no.$rec_no] RES:\n", $res->as_string if TRACE; + my $res_headers = $res->headers; $bytes_recv += $res_headers->header('Content-Length') || (length($res_headers->as_string) + length($res->content)); $res_statuses{int($res->code / 100) .'xx'}++; } - if ( $@ || ! response_matched($exp_res, $res) ) { + if ( $err || ! response_matched($exp_res, $res) ) { $failed_requests++; $rec_errors{$rec_no}++; if ( ERROR ) { @@ -424,7 +425,7 @@ sub run_tests { } } if ( TRACE ) { - LOG " Exception: $@" if $@; + LOG " Exception: $err" if $err; } } else { $successful_requests++;