[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH] DhcpWatch::leases: Check errors



Check error returns from connect() et al (which present as an undef
return from IO::Socket::INET), and from read() (which can be detected
via IO::Handle::error).

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/DhcpWatch/leases.pm |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Osstest/DhcpWatch/leases.pm b/Osstest/DhcpWatch/leases.pm
index 6f142e7..9a74c40 100644
--- a/Osstest/DhcpWatch/leases.pm
+++ b/Osstest/DhcpWatch/leases.pm
@@ -58,6 +58,7 @@ sub check_ip ($$) {
        if (!defined $leases) { return "open $leasesfn: $!"; }
     } else {
        $leases= new IO::Socket::INET(PeerAddr => $leasesfn);
+       if (!defined $leases) { return "connect to $leasesfn: $!"; }
     }
 
     my $lstash= "dhcpleases-$gho->{Guest}";
@@ -163,6 +164,9 @@ sub check_ip ($$) {
 
     if (!$best) {
         $saveas->("$lstash.nolease", 3);
+       if ($leases->error) {
+           return "error reading $leasesfn";
+       }
         return "no active lease";
     }
     $gho->{Ip}= $best->{' addr'};
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.