Subject: | sysread comparison error in Lite.pm |
Date: | Wed, 8 Jun 2016 00:45:26 +0000 |
To: | bug-HTTP-Lite [...] rt.cpan.org |
From: | Greg Cox <gcox [...] mozilla.com> |
======================================================================
# is there a line in the buffer yet?
while ($self->{HTTPReadBuffer} !~ /$EOL/)
{
# nope -- wait for incoming data
my ($inbuf,$bits,$chars) = ("","",0);
vec($bits,fileno($fh),1)=1;
my $nfound = select($bits, undef, $bits, $timeout);
if ($nfound == 0)
{
# Timed out
return undef;
} else {
# Get the data
$chars = sysread($fh, $inbuf, $BLOCKSIZE);
$self->{DEBUG} && $self->DEBUG("sysread $chars bytes");
}
# End of stream?
if ($chars <= 0 && !$!{EAGAIN})
{
last;
}
# tag data onto end of buffer
$self->{HTTPReadBuffer}.=$inbuf;
}
======================================================================
Hi!
We use HTTP-Lite to read server-status from Apache. When things go bad, we
get:
httpd max clients is UNKNOWN: **ePN /usr/lib64/nagios/plugins/mozilla/
check_max_clients.pl: Use of uninitialized value chars in numeric le (=)
at /usr/share/perl5/vendor_perl/HTTP/Lite.pm line 666,.
From HTTP/Lite.pm, the sysread can go into error, leaving $chars = undef.
Falling down, then we get to 'if ($chars <= 0 && !$!{EAGAIN})', which is
then 'if (undef <= 0)', which trips up when under strict/warning pragmas.
Hope this helps.
-Greg