DhcpWatch::leases: Check errors
PATCH 1/1 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).
--- Osstest/DhcpWatch/leases.pm | 4 ++++ 1 file changed, 4 insertions(+)
Osstest/DhcpWatch/leases.pm +4 -0
@@ -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'};
Signature · 1 line
1.7.10.4
Quoted 5 lines · Ian Jackson
Check error returns from
connect()et al (which present as an undef return fromIO::Socket::INET), and fromread()(which can be detected viaIO::Handle::error).Signed-off-by Ian Jackson <[email protected]>
Looks like you have a mixture of tabs and spaces in the second hunk, but otherwise:
Quoted 26 lines
--- Osstest/DhcpWatch/leases.pm | 4 ++++ 1 file changed, 4 insertions(+)Osstest/DhcpWatch/leases.pm +4
-0@@ -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'};
Ian Campbell writes ("Re: [OSSTEST PATCH] DhcpWatch::leases: Check errors"):
Quoted 8 lines · Ian Jackson
Quoted 3 lines
Check error returns from
connect()et al (which present as an undef return fromIO::Socket::INET), and fromread()(which can be detected viaIO::Handle::error).Looks like you have a mixture of tabs and spaces in the second hunk, but otherwise:
Acked-by Ian Campbell <[email protected]>
osstest is full of a mixture of tabs and spaces. It's not the kind of thing I think is worth caring about.
Ian.