2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

killing BlockingCall-Child in UndefFn

git-svn-id: https://svn.fhem.de/fhem/trunk@3046 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2013-04-07 20:03:19 +00:00
parent fa41db571e
commit 077c58359f

View File

@ -201,6 +201,12 @@ PRESENCE_Undef($$)
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
if(defined($hash->{helper}{RUNNING_PID}))
{
BlockingKill($hash->{helper}{RUNNING_PID});
}
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
return undef; return undef;
} }
@ -410,15 +416,15 @@ sub PRESENCE_StartLocalScan($;$)
if($hash->{MODE} eq "local-bluetooth") if($hash->{MODE} eq "local-bluetooth")
{ {
BlockingCall("PRESENCE_DoLocalBluetoothScan", $hash->{NAME}."|".$hash->{ADDRESS}."|".$local, "PRESENCE_ProcessLocalScan", 60); $hash->{helper}{RUNNING_PID} = BlockingCall("PRESENCE_DoLocalBluetoothScan", $hash->{NAME}."|".$hash->{ADDRESS}."|".$local, "PRESENCE_ProcessLocalScan", 60) unless(exists($hash->{helper}{RUNNING_PID}));
} }
elsif($hash->{MODE} eq "lan-ping") elsif($hash->{MODE} eq "lan-ping")
{ {
BlockingCall("PRESENCE_DoLocalPingScan", $hash->{NAME}."|".$hash->{ADDRESS}."|".$local, "PRESENCE_ProcessLocalScan", 60); $hash->{helper}{RUNNING_PID} = BlockingCall("PRESENCE_DoLocalPingScan", $hash->{NAME}."|".$hash->{ADDRESS}."|".$local, "PRESENCE_ProcessLocalScan", 60) unless(exists($hash->{helper}{RUNNING_PID}));
} }
elsif($hash->{MODE} eq "fritzbox") elsif($hash->{MODE} eq "fritzbox")
{ {
BlockingCall("PRESENCE_DoLocalFritzBoxScan", $hash->{NAME}."|".$hash->{ADDRESS}."|".$local."|".AttrVal($hash->{NAME}, "fritzbox_repeater", "0"), "PRESENCE_ProcessLocalScan", 60); $hash->{helper}{RUNNING_PID} = BlockingCall("PRESENCE_DoLocalFritzBoxScan", $hash->{NAME}."|".$hash->{ADDRESS}."|".$local."|".AttrVal($hash->{NAME}, "fritzbox_repeater", "0"), "PRESENCE_ProcessLocalScan", 60) unless(exists($hash->{helper}{RUNNING_PID}));
} }
} }
@ -607,13 +613,17 @@ sub
PRESENCE_ProcessLocalScan($) PRESENCE_ProcessLocalScan($)
{ {
my ($string) = @_; my ($string) = @_;
return unless(defined($string));
my @a = split("\\|",$string); my @a = split("\\|",$string);
my $hash = $defs{$a[0]}; my $hash = $defs{$a[0]};
my $local = $a[1];
return if($hash->{helper}{DISABLED}); return if($hash->{helper}{DISABLED});
my $local = $a[1];
Log GetLogLevel($hash->{NAME}, 5), "PRESENCE_ProcessLocalScan: $string"; Log GetLogLevel($hash->{NAME}, 5), "PRESENCE_ProcessLocalScan: $string";
if($hash->{MODE} eq "fritzbox" and defined($a[3])) if($hash->{MODE} eq "fritzbox" and defined($a[3]))
@ -626,6 +636,7 @@ PRESENCE_ProcessLocalScan($)
} }
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
if($a[2] eq "present") if($a[2] eq "present")
{ {
readingsBulkUpdate($hash, "state", "present"); readingsBulkUpdate($hash, "state", "present");
@ -640,9 +651,10 @@ PRESENCE_ProcessLocalScan($)
Log GetLogLevel($hash->{NAME}, 2), "PRESENCE: error while processing device ".$hash->{NAME}." - ".$a[3]; Log GetLogLevel($hash->{NAME}, 2), "PRESENCE: error while processing device ".$hash->{NAME}." - ".$a[3];
} }
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
delete($hash->{helper}{RUNNING_PID});
#Schedule the next check withing $timeout if it is a regular run #Schedule the next check withing $timeout if it is a regular run
unless($local) unless($local)
{ {