mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
HttpUtils.pm: remove internal timer (Forum #29397)
git-svn-id: https://svn.fhem.de/fhem/trunk@7030 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
baaa355582
commit
dbc0f301fd
@ -58,6 +58,7 @@ sub
|
|||||||
HttpUtils_ConnErr($)
|
HttpUtils_ConnErr($)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
$hash = $hash->{hash};
|
||||||
if(defined($hash->{FD})) {
|
if(defined($hash->{FD})) {
|
||||||
delete($hash->{FD});
|
delete($hash->{FD});
|
||||||
delete($selectlist{$hash});
|
delete($selectlist{$hash});
|
||||||
@ -70,6 +71,7 @@ sub
|
|||||||
HttpUtils_ReadErr($)
|
HttpUtils_ReadErr($)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
$hash = $hash->{hash};
|
||||||
if(defined($hash->{FD})) {
|
if(defined($hash->{FD})) {
|
||||||
delete($hash->{FD});
|
delete($hash->{FD});
|
||||||
delete($selectlist{$hash});
|
delete($selectlist{$hash});
|
||||||
@ -123,11 +125,13 @@ HttpUtils_Connect($)
|
|||||||
if($!{EINPROGRESS} || int($!)==10035) { # Nonblocking connect
|
if($!{EINPROGRESS} || int($!)==10035) { # Nonblocking connect
|
||||||
|
|
||||||
$hash->{FD} = $hash->{conn}->fileno();
|
$hash->{FD} = $hash->{conn}->fileno();
|
||||||
|
my %timerHash = ( hash => $hash );
|
||||||
$hash->{directWriteFn} = sub() {
|
$hash->{directWriteFn} = sub() {
|
||||||
delete($hash->{FD});
|
delete($hash->{FD});
|
||||||
delete($hash->{directWriteFn});
|
delete($hash->{directWriteFn});
|
||||||
delete($selectlist{$hash});
|
delete($selectlist{$hash});
|
||||||
|
|
||||||
|
RemoveInternalTimer(\%timerHash);
|
||||||
my $packed = getsockopt($hash->{conn}, SOL_SOCKET, SO_ERROR);
|
my $packed = getsockopt($hash->{conn}, SOL_SOCKET, SO_ERROR);
|
||||||
my $errno = unpack("I",$packed);
|
my $errno = unpack("I",$packed);
|
||||||
return $hash->{callback}($hash, "$host: ".strerror($errno), "")
|
return $hash->{callback}($hash, "$host: ".strerror($errno), "")
|
||||||
@ -138,7 +142,7 @@ HttpUtils_Connect($)
|
|||||||
$hash->{NAME} = "" if(!defined($hash->{NAME})); #Delete might check it
|
$hash->{NAME} = "" if(!defined($hash->{NAME})); #Delete might check it
|
||||||
$selectlist{$hash} = $hash;
|
$selectlist{$hash} = $hash;
|
||||||
InternalTimer(gettimeofday()+$hash->{timeout},
|
InternalTimer(gettimeofday()+$hash->{timeout},
|
||||||
"HttpUtils_ConnErr", $hash, 0);
|
"HttpUtils_ConnErr", \%timerHash, 0);
|
||||||
return undef;
|
return undef;
|
||||||
} else {
|
} else {
|
||||||
return "connect: $!";
|
return "connect: $!";
|
||||||
@ -220,6 +224,8 @@ HttpUtils_Connect2($)
|
|||||||
if($hash->{callback}) { # Nonblocking read
|
if($hash->{callback}) { # Nonblocking read
|
||||||
$hash->{FD} = $hash->{conn}->fileno();
|
$hash->{FD} = $hash->{conn}->fileno();
|
||||||
$hash->{buf} = "";
|
$hash->{buf} = "";
|
||||||
|
$hash->{NAME} = "" if(!defined($hash->{NAME}));
|
||||||
|
my %timerHash = ( hash => {$hash} );
|
||||||
$hash->{directReadFn} = sub() {
|
$hash->{directReadFn} = sub() {
|
||||||
my $buf;
|
my $buf;
|
||||||
my $len = sysread($hash->{conn},$buf,65536);
|
my $len = sysread($hash->{conn},$buf,65536);
|
||||||
@ -228,6 +234,7 @@ HttpUtils_Connect2($)
|
|||||||
delete($hash->{FD});
|
delete($hash->{FD});
|
||||||
delete($hash->{directReadFn});
|
delete($hash->{directReadFn});
|
||||||
delete($selectlist{$hash});
|
delete($selectlist{$hash});
|
||||||
|
RemoveInternalTimer(\%timerHash);
|
||||||
my ($err, $ret, $redirect) = HttpUtils_ParseAnswer($hash, $hash->{buf});
|
my ($err, $ret, $redirect) = HttpUtils_ParseAnswer($hash, $hash->{buf});
|
||||||
$hash->{callback}($hash, $err, $ret) if(!$redirect);
|
$hash->{callback}($hash, $err, $ret) if(!$redirect);
|
||||||
return;
|
return;
|
||||||
@ -235,7 +242,7 @@ HttpUtils_Connect2($)
|
|||||||
};
|
};
|
||||||
$selectlist{$hash} = $hash;
|
$selectlist{$hash} = $hash;
|
||||||
InternalTimer(gettimeofday()+$hash->{timeout},
|
InternalTimer(gettimeofday()+$hash->{timeout},
|
||||||
"HttpUtils_ReadErr", $hash, 0);
|
"HttpUtils_ReadErr", \%timerHash, 0);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user