summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-03-26 11:52:05 +0100
committerAndrey Andreev <narf@devilix.net>2015-03-26 11:52:05 +0100
commit2f79f9a9e8a5b167ce899609a2058c4d2f480aa8 (patch)
treedcf23bd162805eaf167e5b91597af93d6892cc7e /system/libraries/Session
parent3e2045b3a465e9d70eda44f9c0bc4534c5d3840c (diff)
Improve Session GC for files driver
Close #3701
Diffstat (limited to 'system/libraries/Session')
-rw-r--r--system/libraries/Session/drivers/Session_files_driver.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/system/libraries/Session/drivers/Session_files_driver.php b/system/libraries/Session/drivers/Session_files_driver.php
index 74528e9d2..45da91c46 100644
--- a/system/libraries/Session/drivers/Session_files_driver.php
+++ b/system/libraries/Session/drivers/Session_files_driver.php
@@ -326,7 +326,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
*/
public function gc($maxlifetime)
{
- if ( ! is_dir($this->_config['save_path']) OR ($files = scandir($this->_config['save_path'])) === FALSE)
+ if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)
{
log_message('debug', "Session: Garbage collector couldn't list files under directory '".$this->_config['save_path']."'.");
return FALSE;
@@ -340,7 +340,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
($this->_config['match_ip'] === TRUE ? 72 : 40)
);
- foreach ($files as $file)
+ while (($file = readdir($directory)) !== FALSE)
{
// If the filename doesn't match this pattern, it's either not a session file or is not ours
if ( ! preg_match($pattern, $file)
@@ -354,6 +354,8 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
unlink($this->_config['save_path'].DIRECTORY_SEPARATOR.$file);
}
+ closedir($directory);
+
return TRUE;
}