/** * Wait for the lock * @param float $timeout The timeout to wait before stop trying * @return bool False on error */ public static function waitForLock($timeout = 60.0) { $start = microtime(true); while (Atomic::isLocked() && microtime(true) - $start < $timeout) { usleep(500000); } if (microtime(true) - $start >= $timeout) { return false; } return Atomic::lock(); }
echo " -u Cache update only, do not do the analysis" . PHP_EOL; echo " -f Do the analysis and run only fast analyzers" . PHP_EOL; echo " -d Enable debug features" . PHP_EOL; exit; } $passcode = isset($options['passcode']) ? $options['passcode'] : (isset($options['p']) ? $options['p'] : null); $runAnalysis = !isset($options['update']) && !isset($options['u']); $fastOnly = isset($options['fast']) || isset($options['f']); $debug = isset($options['debug']) || isset($options['d']); $correctPasscode = Config::get("passcode"); if ($correctPasscode) { if ($passcode == null) { echo "Passcode non specificato..."; exit(1); } if (md5($passcode) != $correctPasscode) { echo "Passcode non valido..."; exit(2); } } $locked = Atomic::isLocked(); if ($locked) { echo "Analysis is locked... waiting up to 60 seconds" . PHP_EOL; } Atomic::waitForLock(60.0); if ($debug) { Controller::init(); Config::override("debug", true); } Controller::run($runAnalysis, $fastOnly); Atomic::unlock();