X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FTest.pm;h=0bf89bd6b63206cafc5e5648fb7540a4ddd0a146;hb=b83911b54f10ace3de88f2eb084f2cebb16c59a3;hp=bc5fdce6ea04e6b15b5eb4eac225461fed7fae94;hpb=adb2dc4e4fe814be9903dcde454548f2c22bb111;p=irspy-moved-to-github.git diff --git a/lib/ZOOM/IRSpy/Test.pm b/lib/ZOOM/IRSpy/Test.pm index bc5fdce..0bf89bd 100644 --- a/lib/ZOOM/IRSpy/Test.pm +++ b/lib/ZOOM/IRSpy/Test.pm @@ -1,4 +1,3 @@ -# $Id: Test.pm,v 1.5 2006-10-13 10:07:36 sondberg Exp $ package ZOOM::IRSpy::Test; @@ -6,8 +5,10 @@ use 5.008; use strict; use warnings; +use Scalar::Util; + use Exporter 'import'; -our @EXPORT = qw(isodate); +our @EXPORT = qw(zoom_error_timeout_update zoom_error_timeout_check); =head1 NAME @@ -23,8 +24,11 @@ I<## To follow> =cut + sub subtests { () } +sub timeout { undef } + sub start { my $class = shift(); my($conn) = @_; @@ -33,21 +37,28 @@ sub start { } -sub get_handle { - return $_->{'handle'}; -} +our $max_timeout_errors = $ZOOM::IRSpy::max_timeout_errors; +sub zoom_error_timeout_update { + my ($conn, $exception) = @_; + if ($exception =~ /Timeout/i) { + $conn->record->zoom_error->{TIMEOUT}++; + $conn->log("irspy_test", "Increase timeout error counter to: " . + $conn->record->zoom_error->{TIMEOUT}); + } +} -# Utility function, really nothing to do with IRSpy -sub isodate { - my($time) = @_; +sub zoom_error_timeout_check { + my $conn = shift; - my($sec, $min, $hour, $mday, $mon, $year) = localtime($time); - return sprintf("%04d-%02d-%02dT%02d:%02d:%02d", - $year+1900, $mon+1, $mday, $hour, $min, $sec); -} + if ($conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) { + $conn->log("irspy_test", "Got $max_timeout_errors or more timeouts, give up..."); + return 1; + } + return 0; +} =head1 SEE ALSO