From 4a195e85272b7b1038d78323f4589f9d91069b78 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 2 Nov 2006 13:16:49 +0000 Subject: [PATCH] Add sanity-checks after main loop exists, verifying that all connections have used up their tests, have no active or queued task, and do not have any ZOOM-C level tasks queued. These are all "can't happens" -- but they do in fact happen, and the failure to spot them have wasted many frustrating debugging hours. --- lib/ZOOM/IRSpy.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/ZOOM/IRSpy.pm b/lib/ZOOM/IRSpy.pm index 877f9f4..5cbd307 100644 --- a/lib/ZOOM/IRSpy.pm +++ b/lib/ZOOM/IRSpy.pm @@ -1,4 +1,4 @@ -# $Id: IRSpy.pm,v 1.46 2006-11-01 10:14:09 mike Exp $ +# $Id: IRSpy.pm,v 1.47 2006-11-02 13:16:49 mike Exp $ package ZOOM::IRSpy; @@ -342,6 +342,7 @@ sub check { $conn->log("irspy", "has no more tests: removing"); splice @conn, $i0, 1; $this->_rewrite_record($conn); + $conn->option(rewrote_record => 1); next; } @@ -452,6 +453,27 @@ sub check { } $this->log("irspy", "exiting main loop"); + # Sanity checks: none of the following should ever happen + foreach my $conn (@{ $this->{connections} }) { + my $test = $conn->option("current_test_address"); + my $next = $this->_next_test($test); + if (defined $next) { + warn "$conn (in test '$test') has queued test '$next'"; + } + if (my $task = $conn->current_task()) { + warn "$conn still has an active task $task"; + } + if (my $task = $conn->next_task()) { + warn "$conn still has a queued task $task"; + } + if (!$conn->is_idle()) { + warn "$conn is not idle (still has ZOOM-C level tasks queued)"; + } + if (!$conn->option("rewrote_record")) { + warn "$conn did not rewrite its ZeeRex record"; + } + } + return $nskipped; } -- 1.7.10.4