From 26554221fb785426b0d6b3f7d2d0eb92ab824cb8 Mon Sep 17 00:00:00 2001 From: f0o Date: Tue, 1 Sep 2015 14:49:55 +0100 Subject: [PATCH] Add another safety-net to remove locks if the execution of poller/disco gets aborted or killed --- discovery.php | 1 + poller.php | 1 + 2 files changed, 2 insertions(+) diff --git a/discovery.php b/discovery.php index e3a7366dd3..c72013ec71 100755 --- a/discovery.php +++ b/discovery.php @@ -114,6 +114,7 @@ echo PHP_EOL; foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC") as $device) { if (dbGetLock('discovering.' . $device['device_id'])) { + register_shutdown_function('dbReleaseLock','discovering.'.$device['device_id']); discover_device($device, $options); dbReleaseLock('discovering.' . $device['device_id']); } diff --git a/poller.php b/poller.php index 0440997c32..265486b2a9 100755 --- a/poller.php +++ b/poller.php @@ -118,6 +118,7 @@ if (!isset($query)) { foreach (dbFetch($query) as $device) { $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"); if (dbGetLock('polling.' . $device['device_id'])) { + register_shutdown_function('dbReleaseLock','polling.'.$device['device_id']); poll_device($device, $options); RunRules($device['device_id']); echo "\r\n";