feature: Add a new locking framework that uses flock. (#6858)

Change locks to use flock, as pid checking is not
sufficient when PID Namespaces are involved.
This commit is contained in:
keeperofdakeys
2017-07-03 14:14:36 +09:30
committed by Tony Murray
parent f02b551145
commit 701fbbc29b
3 changed files with 102 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ if (isset($options['h'])) {
$where = ' ';
$doing = 'all';
} elseif ($options['h'] == 'new') {
set_lock('new-discovery');
$new_discovery_lock = \LibreNMS\FileLock::lockOrDie('new-discovery');
$where = 'AND `last_discovered` IS NULL';
$doing = 'new';
} elseif ($options['h']) {
@@ -140,10 +140,13 @@ if ($discovered_devices) {
if ($doing === 'new') {
// We have added a new device by this point so we might want to do some other work
oxidized_reload_nodes();
release_lock('new-discovery');
}
}
if ($doing === 'new') {
$new_discovery_lock->release();
}
$string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $discovered_devices devices discovered in $proctime secs";
d_echo("$string\n");