2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +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:
markusbloch 2013-07-16 18:58:40 +00:00
parent 28690599d4
commit 9500f7a60a

View File

@ -217,6 +217,21 @@ while(1)
$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*$/)
{
print timestamp()."received stop command from client ".$client->peerhost()."\n" if($opt_v);
@ -319,12 +334,17 @@ local $SIG{KILL} = sub {threads->exit();};
my ($write_handle, $address, $timeout) = @_;
my $return;
my $hcitool;
my $nextrun = gettimeofday();
local $SIG{HUP} = sub {$nextrun = gettimeofday();};
if($address and $timeout)
{
while(1)
{
if($write_handle)
{
if($nextrun <= gettimeofday())
{
{
lock($querylocker);
@ -354,7 +374,8 @@ my $hcitool;
$write_handle->send("absence\n");
}
sleep $timeout;
$nextrun = gettimeofday() + $timeout;
}
}