From 1e50116c54ec7ffbaba4622d5481207423ef2bbe Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 00:57:24 -0500 Subject: [PATCH] [ticket/10602] Avoid a race condition. PHPBB3-10602 --- phpBB/includes/functions_messenger.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ae0f7823cc..e837811c86 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -715,9 +715,11 @@ class queue $lock_fp = $this->lock(); - if (!file_exists($this->cache_file) || $config['last_queue_run'] > time() - $config['queue_interval']) + // avoid races, check file existence once + $have_cache_file = file_exists($this->cache_file); + if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) { - if (!file_exists($this->cache_file)) + if (!$have_cache_file) { set_config('last_queue_run', time(), true); }