diff --git a/discovery.php b/discovery.php index a8e48c649..e56f104bf 100755 --- a/discovery.php +++ b/discovery.php @@ -108,6 +108,7 @@ if ($config['distributed_poller'] === true) { 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'])) { discover_device($device, $options); + dbReleaseLock('discovering.' . $device['device_id']); } } diff --git a/includes/sql-schema/update.php b/includes/sql-schema/update.php index 00add08f9..e3e5febd1 100644 --- a/includes/sql-schema/update.php +++ b/includes/sql-schema/update.php @@ -96,6 +96,8 @@ if (!dbGetLock('schema_update')) { exit(1); } //end if +register_shutdown_function('dbReleaseLock','schema_update'); + do { sleep(1); } while (@dbFetchCell('SELECT COUNT(*) FROM `devices` WHERE NOT IS_FREE_LOCK(CONCAT("polling.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("queued.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("discovering.", device_id))') > 0); @@ -134,7 +136,7 @@ foreach ($filelist as $file) { if ($config['db']['extension'] == 'mysqli') { echo mysqli_error($database_link)."\n"; } - else { + else { echo mysql_error()."\n"; } } @@ -169,5 +171,3 @@ if ($updating) { echo "-- Done\n"; } - -dbReleaseLock('schema_update'); diff --git a/poller.php b/poller.php index 8c2b32881..57132457d 100755 --- a/poller.php +++ b/poller.php @@ -114,6 +114,7 @@ foreach (dbFetch($query) as $device) { poll_device($device, $options); RunRules($device['device_id']); echo "\r\n"; + dbReleaseLock('polling.' . $device['device_id']); } $polled_devices++; }