_irspy_to_zeerex() now checks the IRSPY_SAVE_XML environment variable
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy.pm
index 8e6d3ac..f5df4b5 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: IRSpy.pm,v 1.88 2007-09-18 16:57:37 mike Exp $
+# $Id: IRSpy.pm,v 1.90 2008-07-16 11:42:13 mike Exp $
 
 package ZOOM::IRSpy;
 
@@ -230,6 +230,7 @@ sub _next_connection {
     my $i = $this->{modi};
     if (!defined $n) {
        $target = shift @{ $this->{queue} };
+       return undef if !defined $target;
     } else {
        while (1) {
            $target = shift @{ $this->{queue} };
@@ -237,10 +238,11 @@ sub _next_connection {
            my $h = _hash($target);
            my $hmodn = $h % $n;
            last if $hmodn == $i;
-           $this->log("irspy", "'$target' hash $h % $n = $hmodn != $i");
+           #$this->log("irspy", "'$target' hash $h % $n = $hmodn != $i");
        }
     }
 
+    die "oops -- target is undefined" if !defined $target;
     return create ZOOM::IRSpy::Connection($this, $target, async => 1,
                                          timeout => $this->{timeout});
 }
@@ -260,7 +262,9 @@ sub _hash {
 
 sub _irspy_to_zeerex {
     my $this = shift();
-    my($conn, $save_xml) = @_;
+    my($conn) = @_;
+
+    my $save_xml = $ENV{IRSPY_SAVE_XML};
     my $irspy_doc = $conn->record()->{zeerex}->ownerDocument;
 
     if ($save_xml) {
@@ -289,7 +293,7 @@ sub _rewrite_record {
     my($conn) = @_;
 
     $conn->log("irspy", "rewriting XML record");
-    my $rec = $this->_irspy_to_zeerex($conn, $ENV{IRSPY_SAVE_XML});
+    my $rec = $this->_irspy_to_zeerex($conn);
 
     # Since IRSpy can run for a long time between writes back to the
     # database, it's quite possible for the server to have closed the