From: Ian Jackson Subject: [OSSTEST PATCH] DhcpWatch::leases: Check errors Date: Fri, 31 Oct 2014 11:21:29 +0000 Message-ID: <1414754490-30355-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XkAGz-0006RH-6J for xen-devel@lists.xenproject.org; Fri, 31 Oct 2014 11:21:41 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org 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 --- 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