Skip to content

Commit

Permalink
Merge branch 'MDL-50719-fast-locks-MOODLE_31_STABLE' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/brendanheywood/moodle into MOODLE_31_STABLE
  • Loading branch information
andrewnicols committed Feb 27, 2017
2 parents f76f70f + 48f3c57 commit 3b8f30b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/classes/task/manager.php
Expand Up @@ -421,8 +421,16 @@ public static function get_next_adhoc_task($timestart) {

foreach ($records as $record) {

if ($lock = $cronlockfactory->get_lock('adhoc_' . $record->id, 10)) {
if ($lock = $cronlockfactory->get_lock('adhoc_' . $record->id, 0)) {
$classname = '\\' . $record->classname;

// Safety check, see if the task has been already processed by another cron run.
$record = $DB->get_record('task_adhoc', array('id' => $record->id));
if (!$record) {
$lock->release();
continue;
}

$task = self::adhoc_task_from_record($record);
// Safety check in case the task in the DB does not match a real class (maybe something was uninstalled).
if (!$task) {
Expand Down Expand Up @@ -472,7 +480,7 @@ public static function get_next_scheduled_task($timestart) {

foreach ($records as $record) {

if ($lock = $cronlockfactory->get_lock(($record->classname), 10)) {
if ($lock = $cronlockfactory->get_lock(($record->classname), 0)) {
$classname = '\\' . $record->classname;
$task = self::scheduled_task_from_record($record);
// Safety check in case the task in the DB does not match a real class (maybe something was uninstalled).
Expand Down

0 comments on commit 3b8f30b

Please sign in to comment.