Fix #3627: Keep timed locks for more than 5 seconds
Emulated locks for Redis and Memcached now have a TTL
of 300 seconds (the default HTTP request timeout value
on many environments) and 30 attemps, each separated by
sleep(1), are made by the blocked request to try and
obtain a lock if it has been freed.
Additionaly, the blocking time for MySQL's locks,
which are also timed, is also set to 300 seconds.
diff --git a/system/libraries/Session/drivers/Session_database_driver.php b/system/libraries/Session/drivers/Session_database_driver.php
index f496b4f..76c1cf3 100644
--- a/system/libraries/Session/drivers/Session_database_driver.php
+++ b/system/libraries/Session/drivers/Session_database_driver.php
@@ -319,7 +319,7 @@
if ($this->_platform === 'mysql')
{
$arg = $session_id.($this->_config['match_ip'] ? '_'.$_SERVER['REMOTE_ADDR'] : '');
- if ($this->_db->query("SELECT GET_LOCK('".$arg."', 10) AS ci_session_lock")->row()->ci_session_lock)
+ if ($this->_db->query("SELECT GET_LOCK('".$arg."', 300) AS ci_session_lock")->row()->ci_session_lock)
{
$this->_lock = $arg;
return TRUE;