| @@ 313-330 (lines=18) @@ | ||
| 310 | // 30 attempts to obtain a lock, in case another request already has it |
|
| 311 | $lock_key = $this->_key_prefix.$session_id.':lock'; |
|
| 312 | $attempt = 0; |
|
| 313 | do |
|
| 314 | { |
|
| 315 | if ($this->_memcached->get($lock_key)) |
|
| 316 | { |
|
| 317 | sleep(1); |
|
| 318 | continue; |
|
| 319 | } |
|
| 320 | ||
| 321 | if ( ! $this->_memcached->set($lock_key, time(), 300)) |
|
| 322 | { |
|
| 323 | log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id); |
|
| 324 | return $this->_failure; |
|
| 325 | } |
|
| 326 | ||
| 327 | $this->_lock_key = $lock_key; |
|
| 328 | break; |
|
| 329 | } |
|
| 330 | while (++$attempt < 30); |
|
| 331 | ||
| 332 | if ($attempt === 30) |
|
| 333 | { |
|
| @@ 325-342 (lines=18) @@ | ||
| 322 | // 30 attempts to obtain a lock, in case another request already has it |
|
| 323 | $lock_key = $this->_key_prefix.$session_id.':lock'; |
|
| 324 | $attempt = 0; |
|
| 325 | do |
|
| 326 | { |
|
| 327 | if (($ttl = $this->_redis->ttl($lock_key)) > 0) |
|
| 328 | { |
|
| 329 | sleep(1); |
|
| 330 | continue; |
|
| 331 | } |
|
| 332 | ||
| 333 | if ( ! $this->_redis->setex($lock_key, 300, time())) |
|
| 334 | { |
|
| 335 | log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id); |
|
| 336 | return FALSE; |
|
| 337 | } |
|
| 338 | ||
| 339 | $this->_lock_key = $lock_key; |
|
| 340 | break; |
|
| 341 | } |
|
| 342 | while (++$attempt < 30); |
|
| 343 | ||
| 344 | if ($attempt === 30) |
|
| 345 | { |
|