public static function UltimateCronLock::cleanup in Ultimate Cron 7.2
Cleanup expired locks.
File
- ./
ultimate_cron.lock.inc, line 206 - A database-mediated implementation of a locking mechanism.
Class
- UltimateCronLock
- Class for handling lock functions.
Code
public static function cleanup() {
$target = _ultimate_cron_get_transactional_safe_connection();
$class = _ultimate_cron_get_class('job');
$now = microtime(TRUE);
// Cleanup all expired locks.
$count = 0;
do {
$lids = db_select('ultimate_cron_lock', 'l', array(
'target' => $target,
))
->fields('l', array(
'lid',
))
->condition('current', 0)
->condition('expire', $now, '<=')
->range(0, 100)
->execute()
->fetchAll(PDO::FETCH_COLUMN);
if ($lids) {
$count += db_delete('ultimate_cron_lock', array(
'target' => $target,
))
->condition('lid', $lids, 'IN')
->execute();
}
if ($job = $class::$currentJob) {
if ($job
->getSignal('kill')) {
watchdog('ultimate_cron', 'kill signal received', array(), WATCHDOG_NOTICE);
return;
}
}
} while ($lids);
if ($count) {
watchdog('ultimate_cron_lock', 'Released @count expired locks', array(
'@count' => $count,
), WATCHDOG_NOTICE);
}
// Cleanup all released locks.
$count = 0;
do {
$lids = db_select('ultimate_cron_lock', 'l', array(
'target' => $target,
))
->fields('l', array(
'lid',
))
->where('l.current = l.lid')
->range(0, 100)
->execute()
->fetchAll(PDO::FETCH_COLUMN);
if ($lids) {
$count += db_delete('ultimate_cron_lock', array(
'target' => $target,
))
->condition('lid', $lids, 'IN')
->execute();
}
if ($job = $class::$currentJob) {
if ($job
->getSignal('kill')) {
watchdog('ultimate_cron', 'kill signal received', array(), WATCHDOG_NOTICE);
return;
}
}
} while ($lids);
if ($count > 0) {
watchdog('ultimate_cron_lock', 'Cleaned up @count released locks', array(
'@count' => $count,
), WATCHDOG_DEBUG);
}
}