mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
FHEM/HttpUtils.pm: detect parallel nonblocking calls (Forum #120173)
git-svn-id: https://svn.fhem.de/fhem/trunk@24184 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4ef381e2e3
commit
03fe1c8974
@ -82,6 +82,7 @@ HttpUtils_Close($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete($hash->{conn});
|
delete($hash->{conn});
|
||||||
|
delete($hash->{hu_inProgress});
|
||||||
delete($hash->{hu_sslAdded});
|
delete($hash->{hu_sslAdded});
|
||||||
delete($hash->{hu_filecount});
|
delete($hash->{hu_filecount});
|
||||||
delete($hash->{hu_blocking});
|
delete($hash->{hu_blocking});
|
||||||
@ -411,6 +412,7 @@ HttpUtils_Connect($)
|
|||||||
IO::Socket::INET6->new(Proto=>'tcp', Blocking=>0);
|
IO::Socket::INET6->new(Proto=>'tcp', Blocking=>0);
|
||||||
if(!$hash->{conn}) {
|
if(!$hash->{conn}) {
|
||||||
Log3 $hash, $hash->{loglevel}, "HttpUtils: Creating socket: $!";
|
Log3 $hash, $hash->{loglevel}, "HttpUtils: Creating socket: $!";
|
||||||
|
delete($hash->{hu_inProgress});
|
||||||
return $hash->{callback}($hash, "Creating socket: $!", "");
|
return $hash->{callback}($hash, "Creating socket: $!", "");
|
||||||
}
|
}
|
||||||
my $sa = length($iaddr)==4 ? sockaddr_in($port, $iaddr) :
|
my $sa = length($iaddr)==4 ? sockaddr_in($port, $iaddr) :
|
||||||
@ -447,6 +449,7 @@ HttpUtils_Connect($)
|
|||||||
my $err = HttpUtils_Connect2($hash);
|
my $err = HttpUtils_Connect2($hash);
|
||||||
if($err) {
|
if($err) {
|
||||||
Log3 $hash, $hash->{loglevel}, "HttpUtils: $err";
|
Log3 $hash, $hash->{loglevel}, "HttpUtils: $err";
|
||||||
|
delete($hash->{hu_inProgress});
|
||||||
$hash->{callback}($hash, $err, "");
|
$hash->{callback}($hash, $err, "");
|
||||||
}
|
}
|
||||||
return $err;
|
return $err;
|
||||||
@ -553,6 +556,7 @@ HttpUtils_Connect2($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($hash->{noConn2}) {
|
if($hash->{noConn2}) {
|
||||||
|
delete($hash->{hu_inProgress});
|
||||||
$hash->{callback}($hash);
|
$hash->{callback}($hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -636,7 +640,10 @@ HttpUtils_Connect2($)
|
|||||||
delete($selectlist{$hash});
|
delete($selectlist{$hash});
|
||||||
RemoveInternalTimer(\%timerHash);
|
RemoveInternalTimer(\%timerHash);
|
||||||
my ($err, $ret, $redirect) = HttpUtils_ParseAnswer($hash);
|
my ($err, $ret, $redirect) = HttpUtils_ParseAnswer($hash);
|
||||||
$hash->{callback}($hash, $err, $ret) if(!$redirect);
|
if(!$redirect) {
|
||||||
|
delete($hash->{hu_inProgress});
|
||||||
|
$hash->{callback}($hash, $err, $ret);
|
||||||
|
}
|
||||||
|
|
||||||
} elsif($hash->{incrementalTimeout}) { # Forum #85307
|
} elsif($hash->{incrementalTimeout}) { # Forum #85307
|
||||||
RemoveInternalTimer(\%timerHash);
|
RemoveInternalTimer(\%timerHash);
|
||||||
@ -927,8 +934,18 @@ HttpUtils_NonblockingGet($)
|
|||||||
$hash->{hu_blocking} = 0;
|
$hash->{hu_blocking} = 0;
|
||||||
my ($isFile, $fErr, $fContent) = HttpUtils_File($hash);
|
my ($isFile, $fErr, $fContent) = HttpUtils_File($hash);
|
||||||
return $hash->{callback}($hash, $fErr, $fContent) if($isFile);
|
return $hash->{callback}($hash, $fErr, $fContent) if($isFile);
|
||||||
|
if($hash->{hu_inProgress}) {
|
||||||
|
my $m = "Another HttpUtils_NonblockingGet with the same hash is in progress";
|
||||||
|
Log 1, "ERROR: $m";
|
||||||
|
stacktrace();
|
||||||
|
return $hash->{callback}($hash, $m, undef);
|
||||||
|
}
|
||||||
|
$hash->{hu_inProgress} = 1;
|
||||||
my $err = HttpUtils_Connect($hash);
|
my $err = HttpUtils_Connect($hash);
|
||||||
$hash->{callback}($hash, $err, "") if($err);
|
if($err) {
|
||||||
|
delete($hash->{hu_inProgress});
|
||||||
|
$hash->{callback}($hash, $err, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user