diff options
author | Michael Long <mchobbylong@gmail.com> | 2019-03-15 03:47:49 +0100 |
---|---|---|
committer | Michael Long <mchobbylong@gmail.com> | 2019-03-15 03:47:49 +0100 |
commit | 7f8e0cd333176ee943e0c46eb9fe10d31b70d3ce (patch) | |
tree | 4002851a1dbb2b97adb70672c8a0a9dd0fed8508 /system/libraries/Session/drivers | |
parent | 2fbe1fa8e6515f603ac788f2f49c83ba24f485eb (diff) |
Refactor behaviors with different ttl of lock_key
Diffstat (limited to 'system/libraries/Session/drivers')
-rw-r--r-- | system/libraries/Session/drivers/Session_redis_driver.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php index 7262a2300..c9a98b822 100644 --- a/system/libraries/Session/drivers/Session_redis_driver.php +++ b/system/libraries/Session/drivers/Session_redis_driver.php @@ -383,16 +383,16 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle continue; } - $result = ($ttl === -2) - ? $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300)) - : $this->_redis->setex($lock_key, 300, time()); - - if ( ! $result) + if ($ttl === -2 && ! $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300))) { - // Sleep for 0.1s to wait for lock releases. - usleep(100000); + // Sleep for 1s to wait for lock releases. + sleep(1); continue; } + elseif ($ttl === -1 && ! $this->_redis->setex($lock_key, 300, time())) { + log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id); + return FALSE; + } $this->_lock_key = $lock_key; break; |