Subject: | error_handler not handing timeouts properly |
I found that Net::SCP::Expect caused my script to die when a connection timed out even
though I had an error_handler set. I looked into the code and found that it needed some
patching to work correctly, or at least as I expected it to. I have attached my patch and
pasted its contents below:
--- Expect.pm 2006-03-09 11:16:59.000000000 -0500
+++ /Library/Perl/5.8.6/Net/SCP/Expect.pm 2006-03-09 11:17:53.000000000 -0500
@@ -188,9 +188,11 @@
my $err = $scp->before() || $scp->match();
if($err){
if($handler){ $handler->($err) }
- croak("Problem performing scp: $err");
+ else{ croak("Problem performing scp: $err") };
}
- croak("scp timed out while trying to connect to $host");
+ $err = "scp timed out while trying to connect to $host";
+ if($handler){ $handler->($err) }
+ else{ croak($err) };
}
if($verbose){ print $scp->before() }
Subject: | Net-SCP-Expect.patch |
--- Expect.pm 2006-03-09 11:16:59.000000000 -0500
+++ /Library/Perl/5.8.6/Net/SCP/Expect.pm 2006-03-09 11:17:53.000000000 -0500
@@ -188,9 +188,11 @@
my $err = $scp->before() || $scp->match();
if($err){
if($handler){ $handler->($err) }
- croak("Problem performing scp: $err");
+ else{ croak("Problem performing scp: $err") };
}
- croak("scp timed out while trying to connect to $host");
+ $err = "scp timed out while trying to connect to $host";
+ if($handler){ $handler->($err) }
+ else{ croak($err) };
}
if($verbose){ print $scp->before() }