Skip to content
Snippets Groups Projects
Commit ff80f918 authored by Sergey Joseph Ivanov's avatar Sergey Joseph Ivanov
Browse files

Fix file handle comparison

'==' can not compare file handles. We can use fileno() function to
compare numerically file numbers. Code without this returns
"connection successful" when it timeouts and $fd is "undefined".
parent 46240696
No related branches found
No related tags found
No related merge requests found
......@@ -99,7 +99,7 @@ sub handler {
connect($h, $s);
$c->add($h);
my ($fd) = $c->can_write($timeout);
if ($fd == $h) {
if (defined($fd) && (fileno($fd) == fileno($h))) {
my $error = unpack("s", getsockopt($h, Socket::SOL_SOCKET, Socket::SO_ERROR));
if ($error != 0) {
close($h);
......@@ -107,7 +107,7 @@ sub handler {
}
print $h $config->{'prepost'}."\r\n" if ($config->{'prepost'});
($fd) = $c->can_read($timeout);
if ($fd == $h) {
if (defined($fd) && (fileno($fd) == fileno($h))) {
chomp($banner = <$h>);
print $h $config->{'post'} if ($config->{'post'});
close($h);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment