-# $Id: Test.pm,v 1.5 2006-10-13 10:07:36 sondberg Exp $
package ZOOM::IRSpy::Test;
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
=cut
+
sub subtests { () }
+sub timeout { undef }
+
sub start {
my $class = shift();
my($conn) = @_;
}
-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