mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
Blocking.pm: BlockingInformParent: read even if waitForRead is disabled to keep input clear (to prevent FHEM lockup on syswrite) by jensb
git-svn-id: https://svn.fhem.de/fhem/trunk@10047 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
848958034e
commit
df73255cd6
@ -54,7 +54,8 @@ BlockingCall($$@)
|
|||||||
if(!$telnetDevice) {
|
if(!$telnetDevice) {
|
||||||
my $ret = CommandDefine(undef, "$tName telnet 0");
|
my $ret = CommandDefine(undef, "$tName telnet 0");
|
||||||
if($ret) {
|
if($ret) {
|
||||||
$ret = "CallBlockingFn: No telnet port found and cannot create one: $ret";
|
$ret = "BlockingCall ($blockingFn): ".
|
||||||
|
"No telnet port found and cannot create one: $ret";
|
||||||
Log 1, $ret;
|
Log 1, $ret;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@ -72,7 +73,8 @@ BlockingCall($$@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($pid) {
|
if($pid) {
|
||||||
Log 4, "BlockingCall created child ($pid), uses $tName to connect back";
|
Log 4, "BlockingCall ($blockingFn) created child ($pid), ".
|
||||||
|
"uses $tName to connect back";
|
||||||
my %h = ( pid=>$pid, fn=>$blockingFn, finishFn=>$finishFn,
|
my %h = ( pid=>$pid, fn=>$blockingFn, finishFn=>$finishFn,
|
||||||
abortFn=>$abortFn, abortArg=>$abortArg );
|
abortFn=>$abortFn, abortArg=>$abortArg );
|
||||||
if($timeout) {
|
if($timeout) {
|
||||||
@ -105,7 +107,7 @@ BlockingInformParent($;$$)
|
|||||||
my $addr = "localhost:$defs{$telnetDevice}{PORT}";
|
my $addr = "localhost:$defs{$telnetDevice}{PORT}";
|
||||||
$telnetClient = IO::Socket::INET->new(PeerAddr => $addr);
|
$telnetClient = IO::Socket::INET->new(PeerAddr => $addr);
|
||||||
if(!$telnetClient) {
|
if(!$telnetClient) {
|
||||||
Log 1, "CallBlockingFn: Can't connect to $addr: $@";
|
Log 1, "BlockingInformParent ($informFn): Can't connect to $addr: $@";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,6 +131,14 @@ BlockingInformParent($;$$)
|
|||||||
my $len = sysread($telnetClient, $ret, 4096);
|
my $len = sysread($telnetClient, $ret, 4096);
|
||||||
chop($ret);
|
chop($ret);
|
||||||
$ret = undef if(!defined($len));
|
$ret = undef if(!defined($len));
|
||||||
|
} else {
|
||||||
|
# if data is available read anyway to keep input stream clear
|
||||||
|
my $rin = '';
|
||||||
|
vec($rin, $telnetClient->fileno(), 1) = 1;
|
||||||
|
if (select($rin, undef, undef, 0) > 0) {
|
||||||
|
sysread($telnetClient, $ret, 4096);
|
||||||
|
$ret = undef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -178,5 +188,4 @@ BlockingExit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user