2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 19:32:42 +00:00

preventing dead lock of ctlmgr_ctl calls in case of killed thread

git-svn-id: https://svn.fhem.de/fhem/trunk@3206 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2013-05-22 16:09:38 +00:00
parent c9dbd559fa
commit 591a954982

View File

@ -1,4 +1,4 @@
# $Id$
# $Id$
##############################################################################
#
# 73_PRESENCE.pm
@ -540,29 +540,30 @@ PRESENCE_DoLocalPingScan($)
}
sub
sub
PRESENCE_ExecuteFritzBoxCMD($$)
{
my ($name, $cmd) = @_;
my $status;
my $wait;
while(-e "/var/tmp/fhem-PRESENCE-cmd-lock.tmp")
{
$wait = int(rand(4))+2;
Log GetLogLevel($name, 5), "PRESENCE_ExecuteFritzBoxCMD: ($name) - ctlmgr_ctl is locked. waiting $wait seconds...";
sleep $wait;
}
my ($name, $cmd) = @_;
my $status;
my $wait;
qx(touch /var/tmp/fhem-PRESENCE-cmd-lock.tmp);
while(-e "/var/tmp/fhem-PRESENCE-cmd-lock.tmp" and (stat("/var/tmp/fhem-PRESENCE-cmd-lock.tmp"))[9] > (gettimeofday() - 2))
{
$wait = int(rand(4))+2;
Log GetLogLevel($name, 5), "PRESENCE_ExecuteFritzBoxCMD: ($name) - ctlmgr_ctl is locked. waiting $wait seconds...";
sleep $wait;
}
$status = qx($cmd);
unlink("/var/tmp/fhem-PRESENCE-cmd-lock.tmp") if(-e "/var/tmp/fhem-PRESENCE-cmd-lock.tmp");
qx(touch /var/tmp/fhem-PRESENCE-cmd-lock.tmp);
qx(rm /var/tmp/fhem-PRESENCE-cmd-lock.tmp);
$status = qx($cmd);
return $status;
unlink("/var/tmp/fhem-PRESENCE-cmd-lock.tmp") if(-e "/var/tmp/fhem-PRESENCE-cmd-lock.tmp");
return $status;
}
sub