Commit e64f1fa1 authored by Dan Poltawski's avatar Dan Poltawski
Browse files

Merge branch 'MDL-49740-locking-bugs' of https://github.com/brendanheywood/moodle

parents cdc0f4de 894f36ab
......@@ -109,7 +109,7 @@ if ($execute = $options['execute']) {
$predbqueries = $DB->perf_get_queries();
$pretime = microtime(true);
try {
mtrace("Scheduled task: " . $task->get_name());
// NOTE: it would be tricky to move this code to \core\task\manager class,
// because we want to do detailed error reporting.
......@@ -119,15 +119,19 @@ if ($execute = $options['execute']) {
exit(129);
}
if (!$lock = $cronlockfactory->get_lock('\\' . get_class($task), 10)) {
$cronlock->release();
mtrace('Cannot obtain task lock');
exit(130);
}
$task->set_lock($lock);
if (!$task->is_blocking()) {
$cronlock->release();
} else {
$task->set_cron_lock($cronlock);
}
try {
get_mailer('buffer');
$task->execute();
if (isset($predbqueries)) {
......
......@@ -216,7 +216,7 @@ class db_record_lock_factory implements lock_factory {
// Called from the shutdown handler. Must release all open locks.
foreach ($this->openlocks as $key => $unused) {
$lock = new lock($key, $this);
$this->release_lock($lock);
$lock->release();
}
}
}
......@@ -236,7 +236,7 @@ class postgres_lock_factory implements lock_factory {
// Called from the shutdown handler. Must release all open locks.
foreach ($this->openlocks as $key => $unused) {
$lock = new lock($key, $this);
$this->release_lock($lock);
$lock->release();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment