mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 14:48:53 +00:00
[feature/system-cron] Try to work around stealth cron locks
Try to work around stealth cron locks resulting from fatal errors during cron processing. PHPBB3-9596
This commit is contained in:
parent
d6fcea23a4
commit
5c03040ddd
1 changed files with 29 additions and 10 deletions
|
@ -48,17 +48,19 @@ function do_cron($run_tasks)
|
|||
garbage_collection();
|
||||
}
|
||||
|
||||
$cron_lock = new cron_lock;
|
||||
if ($cron_lock->lock())
|
||||
{
|
||||
// Thanks to various fatal errors and lack of try/finally, it is quite easy to leave
|
||||
// the cron lock locked, especially when working on cron-related code.
|
||||
//
|
||||
// Attempt to alleviate the problem by doing setup outside of the lock as much as possible.
|
||||
//
|
||||
// If DEBUG_EXTRA is defined and cron lock cannot be obtained, a message will be printed.
|
||||
|
||||
if ($config['use_system_cron'])
|
||||
{
|
||||
$use_shutdown_function = false;
|
||||
|
||||
include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
|
||||
$cron = new cron_manager;
|
||||
|
||||
$run_tasks = $cron->find_all_ready_tasks();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,7 +68,17 @@ if ($cron_lock->lock())
|
|||
$use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
|
||||
|
||||
output_image();
|
||||
}
|
||||
|
||||
$cron_lock = new cron_lock;
|
||||
if ($cron_lock->lock())
|
||||
{
|
||||
if ($config['use_system_cron'])
|
||||
{
|
||||
$run_tasks = $cron->find_all_ready_tasks();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If invalid task is specified, empty $run_tasks is passed to do_cron which then does nothing
|
||||
$run_tasks = array();
|
||||
$task = $cron->find_task($cron_type);
|
||||
|
@ -95,3 +107,10 @@ if ($cron_lock->lock())
|
|||
do_cron($run_tasks);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (defined('DEBUG_EXTRA'))
|
||||
{
|
||||
echo "Could not obtain cron lock.";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue