mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-08 07:24:21 +00:00
implementing "now" command for instant testing
git-svn-id: https://svn.fhem.de/fhem/trunk@3437 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
28690599d4
commit
9500f7a60a
@ -217,6 +217,21 @@ while(1)
|
|||||||
|
|
||||||
$child_handles{$client} = $new_thread;
|
$child_handles{$client} = $new_thread;
|
||||||
}
|
}
|
||||||
|
elsif(lc($buf) =~ /^\s*now\s*$/)
|
||||||
|
{
|
||||||
|
print timestamp()."received now command from client ".$client->peerhost()."\n" if($opt_v);
|
||||||
|
|
||||||
|
if(defined($child_handles{$client}))
|
||||||
|
{
|
||||||
|
print timestamp()."signalling thread ".$child_handles{$client}->tid()." for an instant test for client ".$client->peerhos$
|
||||||
|
$child_handles{$client}->kill('HUP');
|
||||||
|
$client->send("command accepted\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$client->send("no command running\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
elsif(lc($buf) =~ /^\s*stop\s*$/)
|
elsif(lc($buf) =~ /^\s*stop\s*$/)
|
||||||
{
|
{
|
||||||
print timestamp()."received stop command from client ".$client->peerhost()."\n" if($opt_v);
|
print timestamp()."received stop command from client ".$client->peerhost()."\n" if($opt_v);
|
||||||
@ -319,6 +334,9 @@ local $SIG{KILL} = sub {threads->exit();};
|
|||||||
my ($write_handle, $address, $timeout) = @_;
|
my ($write_handle, $address, $timeout) = @_;
|
||||||
my $return;
|
my $return;
|
||||||
my $hcitool;
|
my $hcitool;
|
||||||
|
my $nextrun = gettimeofday();
|
||||||
|
|
||||||
|
local $SIG{HUP} = sub {$nextrun = gettimeofday();};
|
||||||
|
|
||||||
if($address and $timeout)
|
if($address and $timeout)
|
||||||
{
|
{
|
||||||
@ -326,6 +344,8 @@ my $hcitool;
|
|||||||
{
|
{
|
||||||
if($write_handle)
|
if($write_handle)
|
||||||
{
|
{
|
||||||
|
if($nextrun <= gettimeofday())
|
||||||
|
{
|
||||||
{
|
{
|
||||||
lock($querylocker);
|
lock($querylocker);
|
||||||
if($querylocker gt (time() - 10))
|
if($querylocker gt (time() - 10))
|
||||||
@ -354,7 +374,8 @@ my $hcitool;
|
|||||||
$write_handle->send("absence\n");
|
$write_handle->send("absence\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep $timeout;
|
$nextrun = gettimeofday() + $timeout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user